Ejemplo n.º 1
0
    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")
Ejemplo n.º 2
0
    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")
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)