|
| 1 | +""" |
| 2 | +GitLab API: https://docs.gitlab.com/ee/api/resource_iteration_events.html |
| 3 | +""" |
| 4 | + |
| 5 | +import pytest |
| 6 | +import responses |
| 7 | + |
| 8 | +from gitlab.v4.objects import ProjectIssueResourceIterationEvent |
| 9 | + |
| 10 | +issue_event_content = {"id": 1, "resource_type": "Issue"} |
| 11 | + |
| 12 | + |
| 13 | +@pytest.fixture() |
| 14 | +def resp_list_project_issue_iteration_events(): |
| 15 | + with responses.RequestsMock() as rsps: |
| 16 | + rsps.add( |
| 17 | + method=responses.GET, |
| 18 | + url="http://localhost/api/v4/projects/1/issues/1/resource_iteration_events", |
| 19 | + json=[issue_event_content], |
| 20 | + content_type="application/json", |
| 21 | + status=200, |
| 22 | + ) |
| 23 | + yield rsps |
| 24 | + |
| 25 | + |
| 26 | +@pytest.fixture() |
| 27 | +def resp_get_project_issue_iteration_event(): |
| 28 | + with responses.RequestsMock() as rsps: |
| 29 | + rsps.add( |
| 30 | + method=responses.GET, |
| 31 | + url="http://localhost/api/v4/projects/1/issues/1/resource_iteration_events/1", |
| 32 | + json=issue_event_content, |
| 33 | + content_type="application/json", |
| 34 | + status=200, |
| 35 | + ) |
| 36 | + yield rsps |
| 37 | + |
| 38 | + |
| 39 | +def test_list_project_issue_iteration_events( |
| 40 | + project_issue, resp_list_project_issue_iteration_events |
| 41 | +): |
| 42 | + iteration_events = project_issue.resource_iteration_events.list() |
| 43 | + assert isinstance(iteration_events, list) |
| 44 | + |
| 45 | + iteration_event = iteration_events[0] |
| 46 | + assert isinstance(iteration_event, ProjectIssueResourceIterationEvent) |
| 47 | + assert iteration_event.resource_type == "Issue" |
| 48 | + |
| 49 | + |
| 50 | +def test_get_project_issue_iteration_event( |
| 51 | + project_issue, resp_get_project_issue_iteration_event |
| 52 | +): |
| 53 | + iteration_event = project_issue.resource_iteration_events.get(1) |
| 54 | + assert isinstance(iteration_event, ProjectIssueResourceIterationEvent) |
| 55 | + assert iteration_event.resource_type == "Issue" |
0 commit comments