Exemplo n.º 1
0
 def setUp(self):
     super(CountryMiddlewareTests, self).setUp()
     self.country_middleware = CountryMiddleware()
     self.session_middleware = SessionMiddleware()
     self.authenticated_user = UserFactory.create()
     self.anonymous_user = AnonymousUserFactory.create()
     self.request_factory = RequestFactory()
     self.patcher = patch.object(pygeoip.GeoIP, 'country_code_by_addr', self.mock_country_code_by_addr)
     self.patcher.start()
     self.addCleanup(self.patcher.stop)
Exemplo n.º 2
0
 def setUp(self):
     super(CountryMiddlewareTests, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     self.country_middleware = CountryMiddleware()
     self.session_middleware = SessionMiddleware()
     self.authenticated_user = UserFactory.create()
     self.anonymous_user = AnonymousUserFactory.create()
     self.request_factory = RequestFactory()
     patcher = patch.object(maxminddb, 'open_database')
     patcher.start()
     country_patcher = patch.object(geoip2.database.Reader, 'country', self.mock_country)
     country_patcher.start()
     self.addCleanup(patcher.stop)
     self.addCleanup(country_patcher.stop)