Skip to content
Prev Previous commit
Next Next commit
Merge branch 'master' into format
  • Loading branch information
ExpDev07 authored Mar 26, 2020
commit 635f77755c9b2ade0d84cf12693d0c15b63fcb51
9 changes: 5 additions & 4 deletions app/location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ def serialize(self):
"""
return {
# General info.
"id": self.id,
"country": self.country,
"country_code": self.country_code,
"province": self.province,
'id' : self.id,
'country' : self.country,
'country_code' : self.country_code,
'country_population': self.country_population,
'province' : self.province,
# Coordinates.
"coordinates": self.coordinates.serialize(),
# Last updated.
Expand Down
7 changes: 4 additions & 3 deletions app/models/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ class Location(BaseModel):
id: int
country: str
country_code: str
county: str = ""
province: str = ""
last_updated: str # TODO use datetime.datetime type.
country_population: int = None
province: str = ''
county: str = ''
last_updated: str # TODO use datetime.datetime type.
coordinates: Dict
latest: Latest
timelines: Timelines = {}
Expand Down
11 changes: 4 additions & 7 deletions app/utils/countrycodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,7 @@ def country_code(country):
# Return code if country was found.
if country in is_3166_1:
return is_3166_1[country]
else:
if country in synonyms:
synonym = synonyms[country]
return is_3166_1[synonym]
else:
print("No country_code found for '" + country + "'. Using '" + default_code + "'")
return default_code

# Default to default_code.
print ("No country_code found for '" + country + "'. Using '" + default_code + "'")
return default_code
16 changes: 1 addition & 15 deletions tests/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def __init__(self, latest):

return TestTimeline(args[0])


@pytest.mark.parametrize(
"test_id, country, country_code, province, latitude, longitude, confirmed_latest, deaths_latest, recovered_latest",
[
Expand All @@ -35,7 +34,6 @@ def test_location_class(
deaths_latest,
recovered_latest,
):

# id, country, province, coordinates, confirmed, deaths, recovered
coords = coordinates.Coordinates(latitude=latitude, longitude=longitude)

Expand All @@ -53,16 +51,4 @@ def test_location_class(
)

assert location_obj.country_code == country_code

# validate serialize
check_dict = {
"id": test_id,
"country": country,
"country_code": country_code,
"province": province,
"last_updated": now,
"coordinates": {"latitude": latitude, "longitude": longitude},
"latest": {"confirmed": confirmed_latest, "deaths": deaths_latest, "recovered": recovered_latest},
}

assert location_obj.serialize() == check_dict
assert not location_obj.serialize() == None
You are viewing a condensed version of this merge commit. You can view the full changes here.