Exemplo n.º 1
0
    def test_get_user_by_email(self):
        user1 = {'id': "1", 'name': "John Smith", 'email': '*****@*****.**'}
        user2 = {'id': "2", 'name': "Jane Doe", 'email': '*****@*****.**'}

        users_handlers.insertUserHandler(makeEvent(user1), {})
        users_handlers.insertUserHandler(makeEvent(user2), {})

        resp = users_handlers.getUsersHandler(
            makeEvent(query={'email': '*****@*****.**'}), {})
        self.assertCountEqual(json.loads(resp['body']), [user2])
Exemplo n.º 2
0
    def test_delete_users(self):
        user1 = {'id': "1", 'name': "John Smith"}
        user2 = {'id': "2", 'name': "Jane Doe"}

        users_handlers.insertUserHandler(makeEvent(user1), {})
        users_handlers.insertUserHandler(makeEvent(user2), {})

        resp = users_handlers.deleteUsersHandler({}, {})
        self.assertEqual(resp['statusCode'], '200')

        resp = users_handlers.getUsersHandler({}, {})
        self.assertCountEqual(json.loads(resp['body']), [])
Exemplo n.º 3
0
    def test_update_user_without_id(self):
        user = {'id': "1", 'name': "John Smith"}

        users_handlers.insertUserHandler(makeEvent(user), {})

        updated_user = {'name': "Joe Shmoe"}
        users_handlers.updateUserHandler(
            makeEvent(updated_user, params={'id': '1'}), {})

        updated_user['id'] = '1'
        resp = users_handlers.getUsersHandler({}, {})
        self.assertCountEqual(json.loads(resp['body']), [updated_user])
Exemplo n.º 4
0
    def test_update_user(self):
        user1 = {'id': "1", 'name': "John Smith"}
        user2 = {'id': "2", 'name': "Jane Doe"}

        users_handlers.insertUserHandler(makeEvent(user1), {})
        users_handlers.insertUserHandler(makeEvent(user2), {})

        updated_user = {'id': "1", 'name': "Joe Shmoe"}
        users_handlers.updateUserHandler(
            makeEvent(updated_user, params={'id': '1'}), {})

        resp = users_handlers.getUsersHandler({}, {})
        self.assertCountEqual(json.loads(resp['body']), [user2, updated_user])
Exemplo n.º 5
0
 def test_users_are_initially_empty(self):
     resp = users_handlers.getUsersHandler({}, {})
     self.assertEqual(json.loads(resp['body']), [])
Exemplo n.º 6
0
 def test_get_user_by_nonexistent_email(self):
     resp = users_handlers.getUsersHandler(
         makeEvent(query={'email': '*****@*****.**'}), {})
     self.assertEqual(resp['statusCode'], '200')
     self.assertCountEqual(json.loads(resp['body']), [])
Exemplo n.º 7
0
    def test_delete_empty_users(self):
        resp = users_handlers.deleteUsersHandler({}, {})
        self.assertEqual(resp['statusCode'], '200')

        resp = users_handlers.getUsersHandler({}, {})
        self.assertCountEqual(json.loads(resp['body']), [])