def test_token_not_defined(self): e = Event() c = SecurityContext() h = AnonymousAuthenticationHandler('provider_name', c) h.handle(e) self.assertIsInstance(c.token, AnonymousToken)
def test_token_already_set(self): c = SecurityContext() c.token = Token('key', 'user') e = Event() h = AnonymousAuthenticationHandler('provider_name', c) h.handle(e) self.assertNotIsInstance(c.token, AnonymousToken)