def test__check_token(self): storage = MagicMock() storage.get.return_value = 'vasya' katya_acc = Account('katya') self.assertFalse(katya_acc._check_token('abc', storage)) vasya_acc = Account('vasya') self.assertTrue(vasya_acc._check_token('abc', storage))
def test_create_ro_token(self, patched_uuid4): patched_uuid4.return_value = 'UUID' storage = MagicMock() account = Account('katya') account._check_token = lambda t, s: True account.create_ro_token('abc', storage) storage.set.assert_called_once_with('ro_token:UUID', 'katya')
def test_create_token__wrong_token(self): account = Account('katya') account._check_token = lambda p, s: False with self.assertRaises(InvalidTokenError): account.create_ro_token('abc', None)