def test_fetch_by_code_no_data(self): self.collection_mock.find_one.return_value = None store = AuthCodeStore(collection=self.collection_mock) with self.assertRaises(AuthCodeNotFound): store.fetch_by_code(code="abcd")
def test_fetch_by_code(self): code = "abcd" self.collection_mock.find_one.return_value = self.auth_code_data self.auth_code_data["code"] = "abcd" store = AuthCodeStore(collection=self.collection_mock) auth_code = store.fetch_by_code(code=code) self.collection_mock.find_one.assert_called_with({"code": "abcd"}) self.assertTrue(isinstance(auth_code, AuthorizationCode)) self.assertDictEqual(auth_code.__dict__, self.auth_code_data)