From 0771d969f7ca819d56d09af0e672b44ddc012e28 Mon Sep 17 00:00:00 2001 From: Robert Bradley Date: Sat, 4 Nov 2023 18:09:26 +0000 Subject: [PATCH] fix: 419-fix-selenium-behave-tests --- .../features/validate_council_outputs.feature | 200 +++++++++--------- .../tests/step_defs/test_validate_council.py | 20 +- 2 files changed, 114 insertions(+), 106 deletions(-) diff --git a/uk_bin_collection/tests/features/validate_council_outputs.feature b/uk_bin_collection/tests/features/validate_council_outputs.feature index 68594e2b83..fd3a3d9216 100644 --- a/uk_bin_collection/tests/features/validate_council_outputs.feature +++ b/uk_bin_collection/tests/features/validate_council_outputs.feature @@ -2,107 +2,107 @@ Feature: Test each council output matches expected results Scenario Outline: Validate Council Output Given the council: - When we scrape the data from + When we scrape the data from using and the is set Then the result is valid json And the output should validate against the schema Examples: Testing : - | council | - | AylesburyValeCouncil | - | BasingstokeCouncil | - | BathAndNorthEastSomersetCouncil | - | BCPCouncil | - | BexleyCouncil | - | BlackburnCouncil | - | BoltonCouncil | - | BristolCityCouncil | - | BromleyBoroughCouncil | - | BroxtoweBoroughCouncil | - | BuckinghamshireCouncil | - | BuryCouncil | - | CalderdaleCouncil | - | CannockChaseDistrictCouncil | - | CardiffCouncil | - | CastlepointDistrictCouncil | - | CharnwoodBoroughCouncil | - | ChelmsfordCityCouncil | - | CheshireEastCouncil | - | ConwyCountyBorough | - | CrawleyBoroughCouncil | - | CroydonCouncil | - | DerbyshireDalesDistrictCouncil | - | DoncasterCouncil | - | DurhamCouncil | - | EastCambridgeshireCouncil | - | EastDevonDC | - | EastleighBoroughCouncil | - | EastLindseyDistrictCouncil | - | EastRidingCouncil | - | EastSuffolkCouncil | - | ErewashBoroughCouncil | - | FenlandDistrictCouncil | - | GatesheadCouncil | - | GlasgowCityCouncil | - | GuildfordCouncil | - | HarrogateBoroughCouncil | - | HighPeakCouncil | - | HuntingdonDistrictCouncil | - | KingstonUponThamesCouncil | - | LancasterCityCouncil | - | LeedsCityCouncil | - | LisburnCastlereaghCityCouncil | - | LondonBoroughHounslow | - | MaldonDistrictCouncil | - | MalvernHillsDC | - | ManchesterCityCouncil | - | MertonCouncil | - | MidSussexDistrictCouncil | - | MiltonKeynesCityCouncil | - | NeathPortTalbotCouncil | - | NewarkAndSherwoodDC | - | NewcastleCityCouncil | - | NorthEastLincs | - | NorthKestevenDistrictCouncil | - | NorthLanarkshireCouncil | - | NorthLincolnshireCouncil | - | NorthNorfolkDistrictCouncil | - | NorthNorthamptonshireCouncil | - | NorthSomersetCouncil | - | NorthTynesideCouncil | - | NorthumberlandCouncil | - | PrestonCityCouncil | - | ReigateAndBansteadBoroughCouncil | - | RhonddaCynonTaffCouncil | - | RochdaleCouncil | - | RushcliffeBoroughCouncil | - | RushmoorCouncil | - | SalfordCityCouncil | - | SheffieldCityCouncil | - | SomersetCouncil | - | SouthAyrshireCouncil | - | SouthCambridgeshireCouncil | - | SouthLanarkshireCouncil | - | SouthNorfolkCouncil | - | SouthOxfordshireCouncil | - | SouthTynesideCouncil | - | StaffordshireMoorlandsDistrictCouncil | - | StHelensBC | - | StockportBoroughCouncil | - | StratfordUponAvonCouncil | - | SwaleBoroughCouncil | - | TamesideMBCouncil | - | TonbridgeAndMallingBC | - | TorbayCouncil | - | TorridgeDistrictCouncil | - | ValeofGlamorganCouncil | - | WakefieldCityCouncil | - | WarwickDistrictCouncil | - | WaverleyBoroughCouncil | - | WealdenDistrictCouncil | - | WelhatCouncil | - | WestLothianCouncil | - | WiganBoroughCouncil | - | WiltshireCouncil | - | WindsorAndMaidenheadCouncil | - | WokingBoroughCouncil | - | YorkCouncil | + | council | selenium_url | selenium_mode | + | AylesburyValeCouncil | None | None | + | BasingstokeCouncil | None | None | + | BathAndNorthEastSomersetCouncil | None | None | + | BCPCouncil | None | None | + | BexleyCouncil | None | None | + | BlackburnCouncil | None | None | + | BoltonCouncil | None | None | + | BristolCityCouncil | None | None | + | BromleyBoroughCouncil | None | None | + | BroxtoweBoroughCouncil | http://selenium:4444 | local | + | BuckinghamshireCouncil | http://selenium:4444 | local | + | BuryCouncil | None | None | + | CalderdaleCouncil | None | None | + | CannockChaseDistrictCouncil | None | None | + | CardiffCouncil | None | None | + | CastlepointDistrictCouncil | None | None | + | CharnwoodBoroughCouncil | None | None | + | ChelmsfordCityCouncil | None | None | + | CheshireEastCouncil | None | None | + | ConwyCountyBorough | None | None | + | CrawleyBoroughCouncil | None | None | + | CroydonCouncil | None | None | + | DerbyshireDalesDistrictCouncil | http://selenium:4444 | local | + | DoncasterCouncil | None | None | + | DurhamCouncil | None | None | + | EastCambridgeshireCouncil | None | None | + | EastDevonDC | None | None | + | EastleighBoroughCouncil | None | None | + | EastLindseyDistrictCouncil | http://selenium:4444 | local | + | EastRidingCouncil | None | None | + | EastSuffolkCouncil | http://selenium:4444 | local | + | ErewashBoroughCouncil | None | None | + | FenlandDistrictCouncil | None | None | + | GatesheadCouncil | http://selenium:4444 | local | + | GlasgowCityCouncil | None | None | + | GuildfordCouncil | None | None | + | HarrogateBoroughCouncil | None | None | + | HighPeakCouncil | http://selenium:4444 | local | + | HuntingdonDistrictCouncil | None | None | + | KingstonUponThamesCouncil | None | None | + | LancasterCityCouncil | None | None | + | LeedsCityCouncil | None | None | + | LisburnCastlereaghCityCouncil | None | None | + | LondonBoroughHounslow | None | None | + | MaldonDistrictCouncil | None | None | + | MalvernHillsDC | None | None | + | ManchesterCityCouncil | None | None | + | MertonCouncil | None | None | + | MidSussexDistrictCouncil | None | None | + | MiltonKeynesCityCouncil | None | None | + | NeathPortTalbotCouncil | http://selenium:4444 | local | + | NewarkAndSherwoodDC | None | None | + | NewcastleCityCouncil | None | None | + | NorthEastLincs | None | None | + | NorthKestevenDistrictCouncil | None | None | + | NorthLanarkshireCouncil | None | None | + | NorthLincolnshireCouncil | None | None | + | NorthNorfolkDistrictCouncil | http://selenium:4444 | local | + | NorthNorthamptonshireCouncil | None | None | + | NorthSomersetCouncil | None | None | + | NorthTynesideCouncil | None | None | + | NorthumberlandCouncil | http://selenium:4444 | local | + | PrestonCityCouncil | http://selenium:4444 | local | + | ReigateAndBansteadBoroughCouncil | http://selenium:4444 | local | + | RhonddaCynonTaffCouncil | None | None | + | RochdaleCouncil | None | None | + | RushcliffeBoroughCouncil | http://selenium:4444 | local | + | RushmoorCouncil | None | None | + | SalfordCityCouncil | None | None | + | SheffieldCityCouncil | None | None | + | SomersetCouncil | None | None | + | SouthAyrshireCouncil | None | None | + | SouthCambridgeshireCouncil | None | None | + | SouthLanarkshireCouncil | None | None | + | SouthNorfolkCouncil | None | None | + | SouthOxfordshireCouncil | None | None | + | SouthTynesideCouncil | None | None | + | StaffordshireMoorlandsDistrictCouncil | http://selenium:4444 | local | + | StHelensBC | None | None | + | StockportBoroughCouncil | None | None | + | StratfordUponAvonCouncil | None | None | + | SwaleBoroughCouncil | None | None | + | TamesideMBCouncil | None | None | + | TonbridgeAndMallingBC | None | None | + | TorbayCouncil | None | None | + | TorridgeDistrictCouncil | None | None | + | ValeofGlamorganCouncil | None | None | + | WakefieldCityCouncil | http://selenium:4444 | local | + | WarwickDistrictCouncil | None | None | + | WaverleyBoroughCouncil | None | None | + | WealdenDistrictCouncil | None | None | + | WelhatCouncil | None | None | + | WestLothianCouncil | http://selenium:4444 | local | + | WiganBoroughCouncil | None | None | + | WiltshireCouncil | None | None | + | WindsorAndMaidenheadCouncil | None | None | + | WokingBoroughCouncil | None | None | + | YorkCouncil | None | None | diff --git a/uk_bin_collection/tests/step_defs/test_validate_council.py b/uk_bin_collection/tests/step_defs/test_validate_council.py index 2d26fe6efc..d1c5946b2c 100644 --- a/uk_bin_collection/tests/step_defs/test_validate_council.py +++ b/uk_bin_collection/tests/step_defs/test_validate_council.py @@ -32,10 +32,13 @@ def get_council_step(context, council_name): logging.info(f"Validate Output: {err}") raise (err) - -@when(parsers.parse("we scrape the data from {council}")) -def scrape_step(context, council): +# When we scrape the data from using and the is set. +@when(parsers.parse("we scrape the data from {council} using {selenium_mode} and the {selenium_url} is set")) +def scrape_step(context, council, selenium_mode, selenium_url): context.council = council + context.selenium_mode = selenium_mode + context.selenium_url = selenium_url + args = [council, context.metadata["url"]] if "uprn" in context.metadata: @@ -51,9 +54,14 @@ def scrape_step(context, council): usrn = context.metadata["usrn"] args.append(f"-us={usrn}") # TODO we should somehow run this test with and without this argument passed - if "web_driver" in context.metadata: - web_driver = context.metadata["web_driver"] - args.append(f"-w={web_driver}") + # TODO I do think this would make the testing of the councils a lot longer and cause a double hit from us + + # At the moment the feature file is set to local execution of the selenium so no url will be set + # And it the behave test will execute locally + if selenium_mode != 'None' and selenium_url != 'None': + if selenium_mode != 'local': + web_driver = context.metadata["web_driver"] + args.append(f"-w={web_driver}") if "skip_get_url" in context.metadata: args.append(f"-s")