Skip to content

Commit

Permalink
Merge pull request #480 from skelt0/feat-Add-support-for-Reading-Boro…
Browse files Browse the repository at this point in the history
…ugh-Council
  • Loading branch information
robbrad authored Dec 13, 2023
2 parents 7610e67 + edf9b8e commit 61de327
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Feature: Test each council output matches expected results
| NorthumberlandCouncil | http://selenium:4444 | local |
| NorthWestLeicestershire | http://selenium:4444 | local |
| PrestonCityCouncil | http://selenium:4444 | local |
| ReadingBoroughCouncil | None | None |
| ReigateAndBansteadBoroughCouncil | http://selenium:4444 | local |
| RhonddaCynonTaffCouncil | None | None |
| RochdaleCouncil | None | None |
Expand Down
9 changes: 7 additions & 2 deletions uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@
"web_driver": "http://selenium:4444",
"wiki_name": "Preston City Council"
},
"ReadingBoroughCouncil": {
"url": "https://api.reading.gov.uk/api/collections/310056735",
"wiki_command_url_override": "https://api.reading.gov.uk/api/collections/XXXXXXXX",
"wiki_name": "Reading Borough Council",
"wiki_note": "Replace XXXXXXXX with your property's UPRN."
},
"ReigateAndBansteadBoroughCouncil": {
"skip_get_url": true,
"uprn": "68134867",
Expand Down Expand Up @@ -764,5 +770,4 @@
"url": "https://waste-api.york.gov.uk/api/Collections/GetBinCollectionDataForUprn/",
"wiki_name": "York Council"
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from uk_bin_collection.uk_bin_collection.common import *
from uk_bin_collection.uk_bin_collection.get_bin_data import \
AbstractGetBinDataClass

class CouncilClass(AbstractGetBinDataClass):
"""
Concrete classes have to implement all abstract operations of the
base class. They can also override some operations with a default
implementation.
"""

def parse_data(self, page: str, **kwargs) -> dict:

json_result = json.loads(page.text)

data = {"bins": []}

for collection in json_result['collections']:
bin_type = collection['service']
bin_collection = collection['date'] # Date format is 14/12/2023 00:00:00

dict_data = {
"type": bin_type.replace(" Collection Service"," Bin"),
"collectionDate": datetime.strptime(bin_collection, "%d/%m/%Y %H:%M:%S").strftime(date_format)
}

data["bins"].append(dict_data)

return data

0 comments on commit 61de327

Please sign in to comment.