def test_delete_function(self):
        client, table = init()
        item = {'item': 'I need to finish this test!', 'completed': True}

        todo = create(client, '1', item, 'todo_test', ['completed', 'item'])
        delete(client, '1', todo['todoId'], table.table_name)
        todo_from_get = get_one(client, '1', todo['todoId'], table.table_name)

        # Verify it's an empty dict
        assert not todo_from_get
    def test_update_function(self):
        client, table = init()
        item = {'item': 'I need to finish this test!', 'completed': True}

        todo = create(client, '1', item, 'todo_test', ['completed', 'item'])
        todo['completed'] = False
        todo['item'] = 'Make all the tests!'

        update(client, '1', todo, table.table_name)
        todo_from_get = get_one(client, '1', todo['todoId'], table.table_name)

        # Verify it's not complete
        assert not todo_from_get['completed']
        assert todo_from_get['item'] == 'Make all the tests!'
Пример #3
0
    def test_get_one_function(self):
        client, table = init()
        item = {'item': 'I need to finish this test!', 'completed': True}

        todo = create(client, '1', item, table.table_name,
                      ['completed', 'item'])
        todo_from_get = get_one(client, '1', todo['todoId'], table.table_name)

        # Verify not null
        assert todo_from_get

        # Verify the record is correct
        assert todo_from_get['todoId'] == todo['todoId']
        assert todo_from_get['item'] == todo['item']
        assert todo_from_get['completed'] == todo['completed']
        assert todo_from_get['userId'] == todo['userId']
    def test_delete_handler(self):
        client, table = init()
        item = {'item': 'I need to finish this test!', 'completed': True}

        todo = create(client, '1', item, 'todo_test', ['completed', 'item'])

        event = {
            'queryStringParameters': {
                'id': todo['todoId']
            },
            'requestContext': {
                'authorizer': {
                    'claims': {
                        'cognito:username': '******'
                    }
                }
            }
        }

        handler(event, {})
        todo_from_get = get_one(client, '1', todo['todoId'], table.table_name)

        # Verify it's an empty dict
        assert not todo_from_get