Esempio n. 1
0
async def test_create_update_user(test_cxt):
    user_t_one = await create_todo_user(test_cxt,
                                        TodoUserInput(name='Test Name'))
    new_id = user_t_one.obj_id()
    assert user_t_one.name() == 'Test Name'
    await update_todo_user(test_cxt, new_id, TodoUserInput(name='New Name'))
    user_t_two = await TodoUser.gen(test_cxt, new_id)
    assert user_t_two.name() == 'New Name'
Esempio n. 2
0
def test_get_item():
    pent_context = mem_context()
    user_input = TodoUserInput(name='John Doe')
    user = execute_gen(create_todo_user(pent_context, user_input))
    todo_input_one = TodoItemInput(user_id=user.obj_id(), text='something one')
    todo_one = execute_gen(create_todo_item(pent_context, todo_input_one))
    assert todo_one.text() == 'something one'

    todo_input_two = TodoItemInput(user_id=user.obj_id(), text='something two')
    todo_two = execute_gen(create_todo_item(pent_context, todo_input_two))
    assert todo_two.text() == 'something two'

    todo_user_out = execute_gen(todo_one.gen_user())
    assert todo_user_out.name() == 'John Doe'

    query = '{ todoItem(id: "%s") { text } }' % todo_one.obj_id()
    result = execute_todo_query(query, pent_context)
    assert result.data['todoItem']['text'] == 'something one'

    query = '{ user (id: "%s") { todoItems { text } } }' % user.obj_id()
    result = execute_todo_query(query, pent_context)

    assert len(result.data['user']['todoItems']) == 2
    assert result.data['user']['todoItems'][0]['text'] == 'something one'
    assert result.data['user']['todoItems'][1]['text'] == 'something two'

    first_one_todo_items = execute_gen(user.gen_todo_items(first=1))
    assert len(first_one_todo_items) == 1
    assert first_one_todo_items[0].text() == 'something one'

    query = '{ user (id: "%s") { todoItems(first: 1) { text } } }' % user.obj_id(
    )
    result = execute_todo_query(query, pent_context)
    assert result.data['user']['todoItems'][0]['text'] == 'something one'
Esempio n. 3
0
async def test_gen_item_then_user(test_cxt):
    new_user = await create_todo_user(test_cxt,
                                      TodoUserInput(name='Test Name'))
    todo_input = TodoItemInput(user_id=new_user.obj_id(), text='some text')
    new_todo_item = await create_todo_item(test_cxt, todo_input)
    genned_user = await new_todo_item.gen_user()
    assert genned_user.obj_id() == new_user.obj_id()
Esempio n. 4
0
def test_get_user():
    pent_context = mem_context()
    user_input = TodoUserInput(name='John Doe')
    user = execute_gen(create_todo_user(pent_context, user_input))
    assert user.name() == 'John Doe'
    new_id = user.obj_id()
    result = get_user_name_via_graphql(pent_context, new_id)
    assert result.data['user']['name'] == 'John Doe'
Esempio n. 5
0
def test_get_computed_field():
    pent_context = mem_context()
    user_input = TodoUserInput(name='John Doe')
    user = execute_gen(create_todo_user(pent_context, user_input))
    assert user.name() == 'John Doe'
    new_id = user.obj_id()
    query = '{ user (id: "%s") { capitalizedName } }' % new_id
    result = execute_todo_query(query, pent_context)
    assert result.data['user']['capitalizedName'] == 'JOHN DOE'
Esempio n. 6
0
async def test_gen_pents(test_cxt):
    new_user_id = (await
                   create_todo_user(test_cxt,
                                    TodoUserInput(name='Test Name'))).obj_id()
    todo_input = TodoItemInput(user_id=new_user_id, text='some text')
    new_todo_id = (await create_todo_item(test_cxt, todo_input)).obj_id()
    pent_dict = await Pent.gen_list(test_cxt, [new_user_id, new_todo_id])
    assert len(pent_dict) == 2
    assert isinstance(pent_dict[new_user_id], TodoUser)
    assert isinstance(pent_dict[new_todo_id], TodoItem)
Esempio n. 7
0
async def test_gen_item_list_one_member(test_cxt):
    new_user_id = (await
                   create_todo_user(test_cxt,
                                    TodoUserInput(name='Test Name'))).obj_id()
    todo_input = TodoItemInput(user_id=new_user_id, text='some text')
    new_todo_id = (await create_todo_item(test_cxt, todo_input)).obj_id()
    new_user = await TodoUser.gen(test_cxt, new_user_id)
    new_todos = await new_user.gen_todo_items()
    assert len(new_todos) == 1
    assert new_todos[0].obj_id() == new_todo_id
    assert new_todos[0].text() == 'some text'
Esempio n. 8
0
async def test_gen_item_list_three_members(test_cxt):
    new_user_id = (await
                   create_todo_user(test_cxt,
                                    TodoUserInput(name='Test Name'))).obj_id()
    todo1_id = (await create_todo_item(
        test_cxt, TodoItemInput(user_id=new_user_id, text='text1'))).obj_id()
    todo2_id = (await create_todo_item(
        test_cxt, TodoItemInput(user_id=new_user_id, text='text2'))).obj_id()
    todo3_id = (await create_todo_item(
        test_cxt, TodoItemInput(user_id=new_user_id, text='text3'))).obj_id()
    new_user = await TodoUser.gen(test_cxt, new_user_id)
    new_todos = await new_user.gen_todo_items()
    assert len(new_todos) == 3
    assert new_todos[0].obj_id() == todo1_id
    assert new_todos[0].text() == 'text1'
    assert new_todos[1].obj_id() == todo2_id
    assert new_todos[1].text() == 'text2'
    assert new_todos[2].obj_id() == todo3_id
    assert new_todos[2].text() == 'text3'
async def update_user_resolver(_parent, args, context, *_):
    obj_id = UUID(args['id'])
    name = args['input']['name']
    user_input = TodoUserInput(name=name)
    return await update_todo_user(context, obj_id, user_input)
Esempio n. 10
0
async def create_user_resolver(_parent, args, context, *_):
    user_input = TodoUserInput(name=args['input']['name'])
    return await create_todo_user(context, user_input)
Esempio n. 11
0
async def test_gen_user(test_cxt):
    new_user = await create_todo_user(test_cxt,
                                      TodoUserInput(name='Test Name'))
    genned_user = await TodoUser.gen(test_cxt, new_user.obj_id())
    assert genned_user.name() == 'Test Name'
Esempio n. 12
0
async def test_create_todo_user(test_cxt):
    new_user = await create_todo_user(test_cxt,
                                      TodoUserInput(name='Test Name'))
    assert new_user.name() == 'Test Name'
Esempio n. 13
0
async def test_gen_pent(test_cxt):
    new_user = await create_todo_user(test_cxt,
                                      TodoUserInput(name='Test Name'))
    genned_pent = await Pent.gen(test_cxt, new_user.obj_id())
    assert isinstance(genned_pent, TodoUser)
    assert genned_pent.name() == 'Test Name'
Esempio n. 14
0
async def gen_main():
    pent_context = create_pent_context()
    user = await create_todo_user(pent_context, TodoUserInput(name='Joe'))
    return user