[tests] fix location tests

This commit is contained in:
tobi-wan-kenobi 2022-11-26 12:05:42 +01:00
parent 0bc2c6b8e1
commit 1fef60b32c
2 changed files with 10 additions and 10 deletions

View file

@ -32,8 +32,8 @@ __sources = [
{
"url": "http://ip-api.com/json",
"mapping": {
"latitude": "lat",
"longitude": "lon",
"lat": "latitude",
"lon": "longitude",
"country": "country_name",
"countryCode": "country_code",
"city": "city_name",

View file

@ -14,16 +14,16 @@ def urllib_req(mocker):
def secondaryLocation():
return {
"country": "Middle Earth",
"longitude": "10.0",
"latitude": "20.5",
"ip": "127.0.0.1",
"lon": "10.0",
"lat": "20.5",
"query": "127.0.0.1",
}
@pytest.fixture
def primaryLocation():
return {
"country_name": "Rivia",
"country": "Rivia",
"longitude": "-10.0",
"latitude": "-23",
"ip": "127.0.0.6",
@ -33,7 +33,7 @@ def primaryLocation():
def test_primary_provider(urllib_req, primaryLocation):
urllib_req.urlopen.return_value.read.return_value = json.dumps(primaryLocation)
assert util.location.country() == primaryLocation["country_name"]
assert util.location.country() == primaryLocation["country"]
assert util.location.coordinates() == (
primaryLocation["latitude"],
primaryLocation["longitude"],
@ -48,10 +48,10 @@ def test_secondary_provider(mocker, urllib_req, secondaryLocation):
assert util.location.country() == secondaryLocation["country"]
assert util.location.coordinates() == (
secondaryLocation["latitude"],
secondaryLocation["longitude"],
secondaryLocation["lat"],
secondaryLocation["lon"],
)
assert util.location.public_ip() == secondaryLocation["ip"]
assert util.location.public_ip() == secondaryLocation["query"]
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4