def test_update_task(client):
    """
    Тест изменения задачи
    """

    user1 = UserFactory()
    token = AuthToken.objects.create(user1)[1]
    task = TaskFactory()

    data = {
        'executor': task.executor.pk,
        'manager': task.manager.pk,
        'author': task.pk,
        'title': 'text-task',
        'project': task.project.pk,
        'description': task.description,
        'task_id': task.pk,
    }

    response = client.post(reverse('create-task'),
                           data=data,
                           HTTP_AUTHORIZATION=f'Token {token}')
    task.refresh_from_db()

    assert response.status_code == 200
    assert task.title == data['title']
Ejemplo n.º 2
0
    def test_add_works_hours_failed(self, mocker, client) -> None:
        """
        Тест неудачной отметки потраченного времени
        """

        task = TaskFactory()
        user_one = UserFactory()
        token = AuthToken.objects.create(user_one)[1]

        data = self.__get_data(task, True)

        response = client.post(reverse('add_work_hours'),
                               data=data,
                               HTTP_AUTHORIZATION=f'Token {token}')
        task.refresh_from_db()

        assert response.status_code == 400
Ejemplo n.º 3
0
def test_get_tasks_to_execute(client):
    """
    Тест получения списка задач к исполнению
    """

    user1 = UserFactory()
    user2 = UserFactory()
    token = AuthToken.objects.create(user1)[1]

    TaskFactory(executor=user1, status=Task.Status.enqueued)
    TaskFactory(executor=user1, status=Task.Status.enqueued)
    TaskFactory(executor=user2, status=Task.Status.enqueued)

    response = client.get(reverse('tasks-list') + '?to_execute',
                          HTTP_AUTHORIZATION=f'Token {token}')

    assert response.status_code == 200
    assert len(response.data['results']) == 2
Ejemplo n.º 4
0
def test_get_manager_tasks(client):
    """
    Тест получения списка выставленных задач
    """

    user1 = UserFactory()
    user2 = UserFactory()
    token = AuthToken.objects.create(user1)[1]

    TaskFactory(manager=user1, status=Task.Status.enqueued)
    TaskFactory(manager=user1, status=Task.Status.enqueued)
    TaskFactory(manager=user2, status=Task.Status.enqueued)

    response = client.get(reverse('tasks-list'),
                          HTTP_AUTHORIZATION=f'Token {token}')

    assert response.status_code == 200
    assert len(response.data['results']) == 2
def test_save_description(client):
    """
    Тест сохранение описания задачи
    """

    user1 = UserFactory()
    token = AuthToken.objects.create(user1)[1]
    task = TaskFactory()

    data = {
        'description': 'my new description',
        'task_id': task.pk,
    }
    response = client.post(reverse('save-description'),
                           data=data,
                           HTTP_AUTHORIZATION=f'Token {token}')

    task.refresh_from_db()

    assert response.status_code == 200
    assert task.description == data['description']
Ejemplo n.º 6
0
def test_get_task(client):
    """
    Тест получения данных по задаче
    """

    user1 = UserFactory()
    token = AuthToken.objects.create(user1)[1]

    task = TaskFactory()

    response = client.get(reverse('get-task-detail', args=(task.pk, )), HTTP_AUTHORIZATION=f'Token {token}')

    assert response.status_code == 200
def test_create_comment(client):
    """
    Тест создания комментария
    """

    user = UserFactory()
    token = AuthToken.objects.create(user)[1]
    task = TaskFactory()

    data = {
        'text': 'test comment',
        'task': task.pk,
    }
    response = client.post(reverse('create-comment'),
                           data=data,
                           HTTP_AUTHORIZATION=f'Token {token}')

    assert response.status_code == 200
    assert task.comments.count() == 1