Beispiel #1
0
    def setUp(self):
        self.settings_patcher = patch.object(
            settings, 'GEOIP_LOCATION_MODEL',
            'test_app.models.MyCustomLocation')
        self.settings_patcher.start()

        self.storage = BaseLocationStorage(request=HttpRequest(),
                                           response=HttpResponse())
Beispiel #2
0
class BaseLocationStorageTest(TestCase):
    def setUp(self):
        self.settings_patcher = patch.object(settings, "GEOIP_LOCATION_MODEL", "test_app.models.MyCustomLocation")
        self.settings_patcher.start()

        self.storage = BaseLocationStorage(request=HttpRequest(), response=HttpResponse())

    def tearDown(self):
        self.settings_patcher.stop()

    def test_validate_location(self):
        self.assertFalse(self.storage._validate_location(None))
        self.assertFalse(self.storage._validate_location(Mock()))

        location = any_model(MyCustomLocation)
        self.assertTrue(self.storage._validate_location(location))
Beispiel #3
0
class BaseLocationStorageTest(TestCase):
    def setUp(self):
        self.settings_patcher = patch.object(
            settings, 'GEOIP_LOCATION_MODEL',
            'test_app.models.MyCustomLocation')
        self.settings_patcher.start()

        self.storage = BaseLocationStorage(request=HttpRequest(),
                                           response=HttpResponse())

    def tearDown(self):
        self.settings_patcher.stop()

    def test_validate_location(self):
        self.assertFalse(self.storage._validate_location(None))
        self.assertFalse(self.storage._validate_location(Mock()))

        location = create_custom_location(MyCustomLocation)
        self.assertTrue(self.storage._validate_location(location))
Beispiel #4
0
    def setUp(self):
        self.settings_patcher = patch.object(settings, "GEOIP_LOCATION_MODEL", "test_app.models.MyCustomLocation")
        self.settings_patcher.start()

        self.storage = BaseLocationStorage(request=HttpRequest(), response=HttpResponse())