~sirn/fanboi2

c1f8e48d5062ca982c7bd9392477a4cc8623d32e — Kridsada Thanabulpong 6 years ago 06f8c07
Fix GeoIP2 raising no method error.
2 files changed, 8 insertions(+), 3 deletions(-)

M fanboi2/tests/test_utils.py
M fanboi2/utils/geoip.py
M fanboi2/tests/test_utils.py => fanboi2/tests/test_utils.py +7 -2
@@ 92,11 92,16 @@ class TestGeoIP(unittest.TestCase):
        return geoip

    def _makeGeoIP2(self, country_code=None):
        class MockGeoIP2Response(object):
        class MockGeoIP2CountryResponse(object):
            @property
            def country_code(self):
            def iso_code(self):
                return country_code

        class MockGeoIP2Response(object):
            @property
            def country(self):
                return MockGeoIP2CountryResponse()

        class MockGeoIP2(object):
            def country(self, ip_address):
                return MockGeoIP2Response()

M fanboi2/utils/geoip.py => fanboi2/utils/geoip.py +1 -1
@@ 45,4 45,4 @@ class GeoIP(object):
            except AddressNotFoundError:
                pass
        if response is not None:
            return response.country_code
            return response.country.iso_code