Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding support for Reading Borough Council #480

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading