Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit tests for resource milestone events API
Fixes #1154
- Loading branch information
Oleksii Shkurupii
authored and
Oleksii Shkurupii
committed
Aug 28, 2020
1 parent
fa899d7
commit 1317f4b
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
""" | ||
GitLab API: https://docs.gitlab.com/ee/api/resource_milestone_events.html | ||
""" | ||
|
||
import pytest | ||
import responses | ||
|
||
from gitlab.v4.objects import ( | ||
ProjectIssueResourceMilestoneEvent, | ||
ProjectMergeRequestResourceMilestoneEvent, | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
def resp_merge_request_milestone_events(): | ||
mr_content = {"iid": 1} | ||
events_content = {"id": 1, "resource_type": "MergeRequest"} | ||
with responses.RequestsMock() as rsps: | ||
rsps.add( | ||
method=responses.GET, | ||
url="http://localhost/api/v4/projects/1/merge_requests", | ||
json=[mr_content], | ||
content_type="application/json", | ||
status=200, | ||
) | ||
rsps.add( | ||
method=responses.GET, | ||
url="http://localhost/api/v4/projects/1/merge_requests/1/resource_milestone_events", | ||
json=[events_content], | ||
content_type="application/json", | ||
status=200, | ||
) | ||
yield rsps | ||
|
||
|
||
@pytest.fixture() | ||
def resp_project_issue_milestone_events(): | ||
issue_content = {"iid": 1} | ||
events_content = {"id": 1, "resource_type": "Issue"} | ||
with responses.RequestsMock() as rsps: | ||
rsps.add( | ||
method=responses.GET, | ||
url="http://localhost/api/v4/projects/1/issues", | ||
json=[issue_content], | ||
content_type="application/json", | ||
status=200, | ||
) | ||
rsps.add( | ||
method=responses.GET, | ||
url="http://localhost/api/v4/projects/1/issues/1/resource_milestone_events", | ||
json=[events_content], | ||
content_type="application/json", | ||
status=200, | ||
) | ||
yield rsps | ||
|
||
|
||
def test_project_issue_milestone_events(project, resp_project_issue_milestone_events): | ||
issue = project.issues.list()[0] | ||
milestone_events = issue.resourcemilestoneevents.list() | ||
assert isinstance(milestone_events, list) | ||
milestone_event = milestone_events[0] | ||
assert isinstance(milestone_event, ProjectIssueResourceMilestoneEvent) | ||
assert milestone_event.resource_type == "Issue" | ||
|
||
|
||
def test_merge_request_milestone_events(project, resp_merge_request_milestone_events): | ||
mr = project.mergerequests.list()[0] | ||
milestone_events = mr.resourcemilestoneevents.list() | ||
assert isinstance(milestone_events, list) | ||
milestone_event = milestone_events[0] | ||
assert isinstance(milestone_event, ProjectMergeRequestResourceMilestoneEvent) | ||
assert milestone_event.resource_type == "MergeRequest" |