Exemplo n.º 1
0
def test_fetch_tasks(client, jwt, session):  # pylint:disable=unused-argument
    """Assert that the tasks can be fetched."""
    user = factory_user_model()
    factory_task_service(user.id)

    headers = factory_auth_header(jwt=jwt, claims=TestJwtClaims.staff_role)
    rv = client.get('/api/v1/tasks', headers=headers, content_type='application/json')
    item_list = rv.json
    assert schema_utils.validate(item_list, 'paged_response')[0]
    assert rv.status_code == http_status.HTTP_200_OK
Exemplo n.º 2
0
def test_fetch_task(client, jwt, session):  # pylint:disable=unused-argument
    """Assert that the task can be fetched by id."""
    user = factory_user_model()
    task = factory_task_service(user.id)
    task_id = task._model.id

    headers = factory_auth_header(jwt=jwt, claims=TestJwtClaims.staff_role)
    rv = client.get('/api/v1/tasks/{}'.format(task_id), headers=headers, content_type='application/json')
    assert rv.status_code == http_status.HTTP_200_OK
    assert rv.json.get('name') == task._model.name
Exemplo n.º 3
0
def test_fetch_tasks(session, auth_mock):  # pylint:disable=unused-argument
    """Assert that tasks can be fetched."""
    user = factory_user_model()
    task = factory_task_service(user.id)
    dictionary = task.as_dict()
    name = dictionary['name']

    fetched_task = TaskService.fetch_tasks(task_status=[TaskStatus.OPEN.value],
                                           page=1,
                                           limit=10)

    assert fetched_task['tasks']
    for item in fetched_task['tasks']:
        assert item['name'] == name