def test_deliverable_burned_cost(statistics_api, put_project, post_issue,
                                 post_timesheet, post_deliverable, put_link):
    project = create_project()
    put_project(project)
    bound_deliverable = post_deliverable(project.project_id,
                                         create_deliverable())

    # Issue with default project currency
    bound_issue = post_issue(project.project_id, create_issue())
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(2)))
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(1)))
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(1)))
    # Issue with overriden currency
    bound_issue = post_issue(
        project.project_id,
        create_issue(hour_rate=Money(Decimal(1000), currency=Currency.czk)))
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(10)))
    # Issue without timesheet
    bound_issue = post_issue(project.project_id, create_issue())
    put_link(bound_deliverable.object_id, bound_issue.object_id)

    statistics = statistics_api.get_deliverable_statistics(
        bound_deliverable.object_id)
    assert statistics.burned_cost == Money(Decimal(12402), Currency.czk)
def test_deliverable_estimated_duration(statistics_api, put_project,
                                        post_issue, put_link,
                                        post_deliverable):
    project = create_project()
    put_project(project)
    bound_deliverable = post_deliverable(project.project_id,
                                         create_deliverable())
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(5)))
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(2)))
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(3)))
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=None))
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(0)))
    put_link(bound_deliverable.object_id, bound_issue.object_id)

    statistics = statistics_api.get_deliverable_statistics(
        bound_deliverable.object_id)
    assert statistics.estimated_duration == Decimal(10)
def test_deliverable_estimated_cost(statistics_api, put_project, post_issue,
                                    put_link, post_deliverable):
    project = create_project()
    put_project(project)
    bound_deliverable = post_deliverable(project.project_id,
                                         create_deliverable())

    # Issue with default project currency
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(5)))
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    # Issue with overriden currency
    bound_issue = post_issue(
        project.project_id,
        create_issue(estimated_duration=Decimal(2),
                     hour_rate=Money(amount=Decimal(1000),
                                     currency=Currency.czk)))
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    # Issue without estimated duration
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=None))
    put_link(bound_deliverable.object_id, bound_issue.object_id)

    statistics = statistics_api.get_deliverable_statistics(
        bound_deliverable.object_id)
    assert statistics.estimated_cost == Money(amount=Decimal("5002.5"),
                                              currency=Currency.czk)
def test_deliverable_expenditures_cost(statistics_api, put_project, post_issue,
                                       post_expenditure, post_deliverable,
                                       put_link):
    project = create_project()
    put_project(project)
    bound_deliverable = post_deliverable(project.project_id,
                                         create_deliverable())

    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(5)))
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    post_expenditure(
        bound_issue.object_id,
        create_expenditure(cost=Money(Decimal(10), currency=Currency.czk)))
    post_expenditure(bound_issue.object_id,
                     create_expenditure(status=ExpenditureStatus.submitted))
    post_expenditure(bound_issue.object_id,
                     create_expenditure(status=ExpenditureStatus.refund))
    post_expenditure(
        bound_issue.object_id,
        create_expenditure(cost=Money(Decimal(100), currency=Currency.czk)))
    bound_issue = post_issue(project.project_id, create_issue())
    put_link(bound_deliverable.object_id, bound_issue.object_id)
    post_expenditure(
        bound_issue.object_id,
        create_expenditure(cost=Money(Decimal(1000), currency=Currency.czk)))
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(3)))
    put_link(bound_deliverable.object_id, bound_issue.object_id)

    statistics = statistics_api.get_deliverable_statistics(
        bound_deliverable.object_id)
    assert statistics.burned_expenditures_cost == Money(
        Decimal(1110), Currency.czk)
def test_project_burned_duration(statistics_api, put_project, post_issue,
                                 post_timesheet):
    project = create_project()
    put_project(project)
    # Issue with several timesheets
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(5)))
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(2)))
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(1)))
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(1)))
    # Issue with overtime
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(2)))
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(10)))
    # Estimated issue without timesheet
    post_issue(project.project_id, create_issue(estimated_duration=Decimal(3)))
    # Unestimated issue with timesheet
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=None))
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(10)))
    # Issue estimated to zero
    post_issue(project.project_id, create_issue(estimated_duration=Decimal(0)))

    statistics = statistics_api.get_project_statistics(project.project_id)
    assert statistics.burned_duration == Decimal(24)
Beispiel #6
0
def test_create_link(authorized_api_request, post_issue, put_project):
    project = create_project()
    put_project(project)
    issue1 = post_issue(project.project_id, create_issue())
    issue2 = post_issue(project.project_id, create_issue())

    response = authorized_api_request(
        "PUT", get_link_url(issue1.object_id, issue2.object_id))
    assert response.status_code == 201
def test_project_estimated_duration(statistics_api, put_project, post_issue):
    project = create_project()
    put_project(project)
    post_issue(project.project_id, create_issue(estimated_duration=Decimal(5)))
    post_issue(project.project_id, create_issue(estimated_duration=Decimal(2)))
    post_issue(project.project_id, create_issue(estimated_duration=Decimal(3)))
    post_issue(project.project_id, create_issue(estimated_duration=None))
    post_issue(project.project_id, create_issue(estimated_duration=Decimal(0)))

    statistics = statistics_api.get_project_statistics(project.project_id)
    assert statistics.estimated_duration == Decimal(10)
Beispiel #8
0
def test_delete_issue_with_links(authorized_api_request, post_issue, get_issue,
                                 put_project, put_link):
    project = create_project()
    put_project(project)
    bound_issue1 = post_issue(project.project_id, create_issue())
    bound_issue2 = post_issue(project.project_id, create_issue())
    put_link(bound_issue1.object_id, bound_issue2.object_id)

    authorized_api_request("DELETE",
                           get_issue_url(str(bound_issue1.object_id)))

    with pytest.raises(IssueDoesNotExist):
        get_issue(bound_issue1.object_id)
def test_get_deliverables_filter_related_object(
    authorized_api_request,
    post_deliverable,
    post_issue,
    put_project,
    put_link,
):
    project = create_project()
    put_project(project)
    post_deliverable(project.project_id, MINIMAL_DELIVERABLE)
    full_bound_deliverable = post_deliverable(project.project_id,
                                              FULL_DELIVERABLE)
    issue = post_issue(project.project_id, create_issue())
    put_link(issue.object_id, full_bound_deliverable.object_id)

    response = authorized_api_request(
        "GET",
        get_project_deliverables_url(project.project_id) +
        "?related_object_id={id}".format(id=issue.object_id.full_id))

    assert response.status_code == 200
    assert response.json["deliverables"][0]["id"] == str(
        full_bound_deliverable.object_id)
    del response.json["deliverables"][0]["id"]
    assert response.json == {"deliverables": [FULL_SERIALIZED_DELIVERABLE]}
Beispiel #10
0
def test_project_burned_duration_no_timesheets(statistics_api, put_project,
                                               post_issue):
    project = create_project()
    put_project(project)
    post_issue(project.project_id, create_issue(estimated_duration=Decimal(5)))

    statistics = statistics_api.get_project_statistics(project.project_id)
    assert statistics.burned_duration == Decimal(0)
Beispiel #11
0
def test_project_estimated_cost(statistics_api, put_project, post_issue):
    project = create_project()
    put_project(project)
    # Issue with default project currency
    post_issue(project.project_id, create_issue(estimated_duration=Decimal(5)))
    # Issue with overriden currency
    post_issue(
        project.project_id,
        create_issue(estimated_duration=Decimal(2),
                     hour_rate=Money(amount=Decimal(1000),
                                     currency=Currency.czk)))
    # Issue without estimated duration
    post_issue(project.project_id, create_issue(estimated_duration=None))

    statistics = statistics_api.get_project_statistics(project.project_id)
    assert statistics.estimated_cost == Money(amount=Decimal("5002.5"),
                                              currency=Currency.czk)
Beispiel #12
0
def test_delete_issue_with_timesheets(post_timesheet, authorized_api_request,
                                      post_issue, put_project, get_timesheets):
    project = create_project()
    put_project(project)
    bound_issue = post_issue(project.project_id, create_issue())
    post_timesheet(bound_issue.object_id, create_timesheet())
    request = authorized_api_request("DELETE",
                                     get_issue_url(str(bound_issue.object_id)))
    assert request.status_code == 200
    assert not get_timesheets(bound_issue.object_id)
Beispiel #13
0
def test_project_expenditures_cost_no_expenditures(statistics_api, put_project,
                                                   post_issue,
                                                   post_expenditure):
    project = create_project()
    put_project(project)
    post_issue(project.project_id, create_issue())

    statistics = statistics_api.get_project_statistics(project.project_id)
    assert statistics.burned_expenditures_cost == Money(
        Decimal(0), Currency.czk)
Beispiel #14
0
def test_issue_progress_issue_no_timesheets(statistics_api, put_project,
                                            post_issue):
    project = create_project()
    put_project(project)

    # Issue without timesheets
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(5)))

    statistics = statistics_api.get_entity_statistics(bound_issue.object_id)
    assert statistics.progress == Decimal(0)
Beispiel #15
0
def test_delete_issue(authorized_api_request, post_issue, get_issue,
                      put_project):
    project = create_project()
    put_project(project)
    issue = create_issue()
    bound_issue = post_issue(project.project_id, issue)

    authorized_api_request("DELETE", get_issue_url(str(bound_issue.object_id)))

    with pytest.raises(IssueDoesNotExist):
        get_issue(bound_issue.object_id)
Beispiel #16
0
def test_issue_estimated_duration_no_estimate(
    statistics_api,
    put_project,
    post_issue,
):
    project = create_project()
    put_project(project)
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=None))

    statistics = statistics_api.get_entity_statistics(bound_issue.object_id)
    assert statistics.estimated_duration == Decimal(0)
Beispiel #17
0
def test_issue_burned_cost_no_timesheets(
    statistics_api,
    put_project,
    post_issue,
):
    project = create_project()
    put_project(project)

    # Issue without timesheet
    bound_issue = post_issue(project.project_id, create_issue())

    statistics = statistics_api.get_entity_statistics(bound_issue.object_id)
    assert statistics.burned_cost == Money(Decimal(0), Currency.czk)
Beispiel #18
0
def test_get_timesheets_limit(post_timesheet, authorized_api_request, post_issue, put_project):
    project = create_project()
    put_project(project)
    bound_issue = post_issue(project.project_id, create_issue())
    bound_timesheet = post_timesheet(bound_issue.object_id, create_timesheet(description="limit"))
    post_timesheet(bound_issue.object_id, create_timesheet())
    response = authorized_api_request(
        "GET",
        get_timesheet_url(bound_issue.object_id) + "?limit=1",
    )
    assert response.status_code == 200
    assert len(response.json["timesheets"]) == 1
    assert response.json["timesheets"][0]["description"] == bound_timesheet.description
Beispiel #19
0
def test_issue_overall_progress_issue(statistics_api, put_project, post_issue,
                                      post_timesheet):
    project = create_project()
    put_project(project)

    # Issue with several timesheets
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(5)))
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(2)))

    statistics = statistics_api.get_entity_statistics(bound_issue.object_id)
    assert statistics.overall_progress == Decimal("0.4")
Beispiel #20
0
def test_delete_expenditure(post_expenditure, authorized_api_request,
                            post_issue, put_project, get_expenditures):
    project = create_project()
    put_project(project)
    bound_issue = post_issue(project.project_id, create_issue())
    bound_expenditure = post_expenditure(bound_issue.object_id,
                                         create_expenditure())
    response = authorized_api_request(
        "DELETE",
        get_expenditure_url(bound_expenditure.simple_id.simple_id),
    )
    assert response.status_code == 200
    assert not get_expenditures(bound_issue.object_id)
Beispiel #21
0
def test_issue_overall_progress_issue_unestimated(
    statistics_api,
    put_project,
    post_issue,
):
    project = create_project()
    put_project(project)

    # Issue with several timesheets
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=None))

    statistics = statistics_api.get_entity_statistics(bound_issue.object_id)
    assert statistics.overall_progress is None
Beispiel #22
0
def test_issue_expenditures_cost_no_expenditures(
    statistics_api,
    put_project,
    post_issue,
):
    project = create_project()
    put_project(project)

    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(5)))

    statistics = statistics_api.get_entity_statistics(bound_issue.object_id)
    assert statistics.burned_expenditures_cost == Money(
        Decimal(0), Currency.czk)
Beispiel #23
0
def test_issue_estimated_cost_no_estimate(
    statistics_api,
    put_project,
    post_issue,
):
    project = create_project()
    put_project(project)

    # Issue without estimated duration
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=None))

    statistics = statistics_api.get_entity_statistics(bound_issue.object_id)
    assert statistics.estimated_cost == Money(amount=Decimal(0),
                                              currency=Currency.czk)
Beispiel #24
0
def test_issue_estimated_cost_default_currency(
    statistics_api,
    put_project,
    post_issue,
):
    project = create_project()
    put_project(project)

    # Issue with default project currency
    bound_issue = post_issue(project.project_id,
                             create_issue(estimated_duration=Decimal(5)))

    statistics = statistics_api.get_entity_statistics(bound_issue.object_id)
    assert statistics.estimated_cost == Money(amount=Decimal("3002.5"),
                                              currency=Currency.czk)
Beispiel #25
0
def test_post_full_expenditure(put_project, post_issue, authorized_api_request,
                               get_expenditures):
    project = create_project()
    put_project(project)
    bound_issue = post_issue(project.project_id, create_issue())
    response = authorized_api_request(
        "POST", get_expenditure_url(bound_issue.object_id),
        {"expenditure": FULL_SERIALIZED_EXPENDITURE})
    assert response.status_code == 201
    expenditures = get_expenditures(bound_issue.object_id)
    assert len(expenditures) == 1
    assert expenditures[0] == BoundExpenditure(
        simple_id=expenditures[0].simple_id,
        expenditure=FULL_EXPENDITURE,
    )
def test_delete_deliverable_with_link(authorized_api_request, post_deliverable,
                                      get_deliverable, put_project, put_link,
                                      post_issue):
    project = create_project()
    put_project(project)
    bound_deliverable = post_deliverable(project.project_id,
                                         create_deliverable())
    bound_issue = post_issue(project.project_id, create_issue())
    put_link(bound_deliverable.object_id, bound_issue.object_id)

    authorized_api_request(
        "DELETE", get_deliverable_url(str(bound_deliverable.object_id)))

    with pytest.raises(DeliverableDoesNotExist):
        get_deliverable(bound_deliverable.object_id)
Beispiel #27
0
def test_issue_burned_cost_overriden_currency(statistics_api, put_project,
                                              post_issue, post_timesheet,
                                              post_deliverable, put_link):
    project = create_project()
    put_project(project)

    # Issue with overriden currency
    bound_issue = post_issue(
        project.project_id,
        create_issue(hour_rate=Money(Decimal(1000), currency=Currency.czk)))
    post_timesheet(bound_issue.object_id,
                   create_timesheet(duration=Decimal(10)))

    statistics = statistics_api.get_entity_statistics(bound_issue.object_id)
    assert statistics.burned_cost == Money(Decimal(10000), Currency.czk)
Beispiel #28
0
def test_post_timesheet(put_project, post_issue, authorized_api_request, get_timesheets):
    project = create_project()
    put_project(project)
    bound_issue = post_issue(project.project_id, create_issue())
    response = authorized_api_request(
        "POST",
        get_timesheet_url(bound_issue.object_id),
        {"timesheet": SERIALIZED_TIMESHEET}
    )
    assert response.status_code == 201
    timesheets = get_timesheets(bound_issue.object_id)
    assert len(timesheets) == 1
    assert timesheets[0] == BoundTimesheet(
        simple_id=timesheets[0].simple_id,
        timesheet=create_timesheet(),
    )
Beispiel #29
0
def test_get_expenditures_offset(post_expenditure, authorized_api_request,
                                 post_issue, put_project):
    project = create_project()
    put_project(project)
    bound_issue = post_issue(project.project_id, create_issue())
    post_expenditure(bound_issue.object_id, create_expenditure())
    bound_expenditure = post_expenditure(
        bound_issue.object_id, create_expenditure(description="offset"))
    response = authorized_api_request(
        "GET",
        get_expenditure_url(bound_issue.object_id) + "?offset=1",
    )
    assert response.status_code == 200
    assert len(response.json["expenditures"]) == 1
    assert response.json["expenditures"][0][
        "description"] == bound_expenditure.description
Beispiel #30
0
def test_delete_timesheet(
        post_timesheet,
        authorized_api_request,
        post_issue,
        put_project,
        get_timesheets
):
    project = create_project()
    put_project(project)
    bound_issue = post_issue(project.project_id, create_issue())
    bound_timesheet = post_timesheet(bound_issue.object_id, create_timesheet())
    response = authorized_api_request(
        "DELETE",
        get_timesheet_url(bound_timesheet.simple_id.simple_id),
    )
    assert response.status_code == 200
    assert not get_timesheets(bound_issue.object_id)