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())
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))
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))
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())