[tests] fix location tests
This commit is contained in:
parent
0bc2c6b8e1
commit
1fef60b32c
2 changed files with 10 additions and 10 deletions
|
@ -32,8 +32,8 @@ __sources = [
|
||||||
{
|
{
|
||||||
"url": "http://ip-api.com/json",
|
"url": "http://ip-api.com/json",
|
||||||
"mapping": {
|
"mapping": {
|
||||||
"latitude": "lat",
|
"lat": "latitude",
|
||||||
"longitude": "lon",
|
"lon": "longitude",
|
||||||
"country": "country_name",
|
"country": "country_name",
|
||||||
"countryCode": "country_code",
|
"countryCode": "country_code",
|
||||||
"city": "city_name",
|
"city": "city_name",
|
||||||
|
|
|
@ -14,16 +14,16 @@ def urllib_req(mocker):
|
||||||
def secondaryLocation():
|
def secondaryLocation():
|
||||||
return {
|
return {
|
||||||
"country": "Middle Earth",
|
"country": "Middle Earth",
|
||||||
"longitude": "10.0",
|
"lon": "10.0",
|
||||||
"latitude": "20.5",
|
"lat": "20.5",
|
||||||
"ip": "127.0.0.1",
|
"query": "127.0.0.1",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def primaryLocation():
|
def primaryLocation():
|
||||||
return {
|
return {
|
||||||
"country_name": "Rivia",
|
"country": "Rivia",
|
||||||
"longitude": "-10.0",
|
"longitude": "-10.0",
|
||||||
"latitude": "-23",
|
"latitude": "-23",
|
||||||
"ip": "127.0.0.6",
|
"ip": "127.0.0.6",
|
||||||
|
@ -33,7 +33,7 @@ def primaryLocation():
|
||||||
def test_primary_provider(urllib_req, primaryLocation):
|
def test_primary_provider(urllib_req, primaryLocation):
|
||||||
urllib_req.urlopen.return_value.read.return_value = json.dumps(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() == (
|
assert util.location.coordinates() == (
|
||||||
primaryLocation["latitude"],
|
primaryLocation["latitude"],
|
||||||
primaryLocation["longitude"],
|
primaryLocation["longitude"],
|
||||||
|
@ -48,10 +48,10 @@ def test_secondary_provider(mocker, urllib_req, secondaryLocation):
|
||||||
|
|
||||||
assert util.location.country() == secondaryLocation["country"]
|
assert util.location.country() == secondaryLocation["country"]
|
||||||
assert util.location.coordinates() == (
|
assert util.location.coordinates() == (
|
||||||
secondaryLocation["latitude"],
|
secondaryLocation["lat"],
|
||||||
secondaryLocation["longitude"],
|
secondaryLocation["lon"],
|
||||||
)
|
)
|
||||||
assert util.location.public_ip() == secondaryLocation["ip"]
|
assert util.location.public_ip() == secondaryLocation["query"]
|
||||||
|
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue