def test_to_params(self): req = Request('127.0.0.2', 'python/tests', 'https://localmachine') self.assertEqual({ 'user_ip': '127.0.0.2', 'user_agent': 'python/tests', 'referrer': 'https://localmachine', }, req.as_params())
def test_from_django_request(self): req = Request.from_django_request(Mock(META={ 'REMOTE_ADDR': '127.0.0.2', 'HTTP_USER_AGENT': 'python/tests', 'HTTP_REFERRER': 'referrer', })) self.assertEqual('127.0.0.2', req.ip_address) self.assertEqual('python/tests', req.user_agent) self.assertEqual('referrer', req.referrer)
def test_check(self): client.check(Request(), comment=Comment('my comment')) self.assertTrue(self.connection.check.called)
def test_submit(self): client.submit(Request(), comment=Comment('my comment'), is_spam=True) self.assertTrue(self.connection.submit.called)