def test_is_valid_token_invalid(self): """ Tests is_valid_token with invalid token is_valid_token checks that the token provided by the form matches token described in the settings file. This function call should return false. """ builder = EnvironBuilder(method='POST', data={'token': 'imarobot'}) env = builder.get_environ() req = Request(env) self.assertFalse(handler.is_valid_token(req))
def test_is_valid_token_valid(self): """ Tests is_valid_token with TOKEN defined in conf.py is_valid_token checks that the token provided by the form matches token described in the settings file. This function call should return true. """ builder = EnvironBuilder(method='POST', data={'token': conf.TOKEN}) env = builder.get_environ() req = Request(env) self.assertTrue(handler.is_valid_token(req))