示例#1
0
    async def setUpClass(cls) -> None:
        # repository backed by a fresh database
        test_db = await mongo_factory.create()
        UserRepositoryTestCase._users = mongo_user_repository_factory(db=test_db)

        # insert dummy entries
        dummy = dummies.create()
        await UserRepositoryTestCase._users.insert(dummy)
示例#2
0
    async def test_put_user_from_json(self):
        dummy_data = dummies.create().__dict__

        response = await self.client.put(UserView.__route__, json=dummy_data)

        self.assertEqual(response.status, 200)

        json_response = await response.json()
        self.assertIsNotNone(json_response)
        self.assertIn('inserted_id', json_response)
示例#3
0
    async def test_post_credentials_to_get_auth_token(self):
        dummy_data = dummies.create().__dict__

        await self.client.put(UserView.__route__, json=dummy_data)

        response = await self.client.post(AuthView.__route__, json=dummy_data)

        json_response = await response.json()
        self.assertEqual(response.status, 200)
        self.assertIsNotNone(json_response)
        self.assertIn('token', json_response)
示例#4
0
 def test_create_user_passing_attributes_by_kwargs(self):
     kwargs = dummies.create().__dict__
     user = User(**kwargs)
     self.assertEqual(user.name, kwargs['name'])
     self.assertEqual(user.password, kwargs['password'])
 async def test_insert_user(self):
     user = dummies.create()
     repo_id = await self.users.insert(user)
     self.assertIsNotNone(repo_id)
示例#6
0
 async def insert_dummy(self):
     dummy = dummies.create()
     await self.users.insert(dummy)
     return dummy