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)
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_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
def test_list_timesheets_offset(timesheets_model): timesheet = create_timesheet() timesheets_model.create_timesheet(ENTITY_ID, timesheet) bound_timesheet = timesheets_model.create_timesheet(ENTITY_ID, timesheet) assert timesheets_model.get_timesheets(ENTITY_ID, 1, 1) == [bound_timesheet]
def test_timesheets_limit(timesheets_model): timesheet = create_timesheet() bound_timesheet = timesheets_model.create_timesheet(ENTITY_ID, timesheet) timesheets_model.create_timesheet(ENTITY_ID, timesheet) assert timesheets_model.get_timesheets(ENTITY_ID, 0, 1) == [bound_timesheet]
def test_create_timesheet(timesheets_model): timesheet = create_timesheet() bound_timesheet = timesheets_model.create_timesheet(ENTITY_ID, timesheet) assert bound_timesheet == BoundTimesheet(bound_timesheet.simple_id, timesheet) assert timesheets_model.get_timesheets(ENTITY_ID, 0, 1)
def test_get_timesheets(timesheets_model): timesheet = create_timesheet() bound_timesheet = timesheets_model.create_timesheet(ENTITY_ID, timesheet) timesheets_model.create_timesheet(OTHER_PROJECT_ENTITY_ID, timesheet) assert timesheets_model.get_timesheets(ENTITY_ID, 0, 1) == [bound_timesheet]
def test_issue_overall_progress_issue_overtime(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("4.5"))) statistics = statistics_api.get_entity_statistics(bound_issue.object_id) assert statistics.overall_progress == Decimal("1.5")
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)
def test_issue_burned_cost_default_currency( statistics_api, put_project, post_issue, post_timesheet, ): project = create_project() put_project(project) # Issue with default project currency bound_issue = post_issue(project.project_id, create_issue()) 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))) statistics = statistics_api.get_entity_statistics(bound_issue.object_id) assert statistics.burned_cost == Money(Decimal(2402), Currency.czk)
def test_issue_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))) statistics = statistics_api.get_entity_statistics(bound_issue.object_id) assert statistics.burned_duration == Decimal(4)
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)
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(), )
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)
def test_get_timesheets( 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()) response = authorized_api_request( "GET", get_timesheet_url(bound_issue.object_id), ) assert response.status_code == 200 assert len(response.json["timesheets"]) == 1 assert response.json["timesheets"][0] == { **SERIALIZED_TIMESHEET, "id": bound_timesheet.simple_id.simple_id }
def test_deliverable_overall_progress(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 several timesheets bound_issue = post_issue(project.project_id, create_issue(estimated_duration=Decimal(5))) 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 overtime bound_issue = post_issue(project.project_id, create_issue(estimated_duration=Decimal(2))) put_link(bound_deliverable.object_id, bound_issue.object_id) post_timesheet(bound_issue.object_id, create_timesheet(duration=Decimal(10))) # Estimated issue without timesheet bound_issue = post_issue(project.project_id, create_issue(estimated_duration=Decimal(3))) put_link(bound_deliverable.object_id, bound_issue.object_id) # Unestimated issue with timesheet bound_issue = post_issue(project.project_id, create_issue(estimated_duration=None)) put_link(bound_deliverable.object_id, bound_issue.object_id) post_timesheet(bound_issue.object_id, create_timesheet(duration=Decimal(10))) # Issue estimated to zero bound_issue = post_issue(project.project_id, create_issue(estimated_duration=Decimal(0))) 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) post_timesheet(bound_issue.object_id, create_timesheet(duration=Decimal(10))) statistics = statistics_api.get_deliverable_statistics( bound_deliverable.object_id) assert statistics.overall_progress == Decimal("3.4")
def test_delete_entity_timesheets(timesheets_model): timesheet = create_timesheet() timesheets_model.create_timesheet(ENTITY_ID, timesheet) timesheets_model.delete_entity_timesheets(ENTITY_ID) assert not timesheets_model.get_timesheets(ENTITY_ID, 0, 1)
def test_delete_timesheet(timesheets_model): timesheet = create_timesheet() bound_timesheet = timesheets_model.create_timesheet(ENTITY_ID, timesheet) timesheets_model.delete_timesheet(bound_timesheet.simple_id) assert not timesheets_model.get_timesheets(ENTITY_ID, 0, 1)