-
-
Notifications
You must be signed in to change notification settings - Fork 877
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test_user allow_on_cloud, with appropriate fixes to jira.resources * update test_generic_resource * update search_allowed_users_for_issue() for Jira Cloud * add a search function to the Jira Cloud tests * add test_search_users() to allow_on_cloud
- Loading branch information
Showing
5 changed files
with
78 additions
and
60 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
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
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
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 |
---|---|---|
@@ -1,55 +1,38 @@ | ||
import unittest | ||
import pytest | ||
|
||
from flaky import flaky | ||
import jira.resources | ||
|
||
from jira.resources import ( | ||
Group, | ||
Issue, | ||
Project, | ||
Role, | ||
UnknownResource, | ||
cls_for_resource, | ||
) | ||
MOCK_URL = "http://customized-jira.com/rest/" | ||
|
||
|
||
@flaky | ||
class ResourceTests(unittest.TestCase): | ||
def setUp(self): | ||
pass | ||
def url_test_case(example_url: str): | ||
return f"{MOCK_URL}{example_url}" | ||
|
||
def test_cls_for_resource(self): | ||
self.assertEqual( | ||
cls_for_resource( | ||
"https://jira.atlassian.com/rest/\ | ||
api/latest/issue/JRA-1330" | ||
), | ||
Issue, | ||
) | ||
self.assertEqual( | ||
cls_for_resource( | ||
"http://localhost:2990/jira/rest/\ | ||
api/latest/project/BULK" | ||
), | ||
Project, | ||
) | ||
self.assertEqual( | ||
cls_for_resource( | ||
"http://imaginary-jira.com/rest/\ | ||
api/latest/project/IMG/role/10002" | ||
), | ||
Role, | ||
) | ||
self.assertEqual( | ||
cls_for_resource( | ||
"http://customized-jira.com/rest/\ | ||
plugin-resource/4.5/json/getMyObject" | ||
), | ||
UnknownResource, | ||
) | ||
self.assertEqual( | ||
cls_for_resource( | ||
"http://customized-jira.com/rest/\ | ||
group?groupname=bla" | ||
), | ||
Group, | ||
) | ||
|
||
class TestResource: | ||
@pytest.mark.parametrize( | ||
["example_url", "expected_class"], | ||
# fmt: off | ||
[ | ||
(url_test_case("api/latest/issue/JRA-1330"), jira.resources.Issue), | ||
(url_test_case("api/latest/project/BULK"), jira.resources.Project), | ||
(url_test_case("api/latest/project/IMG/role/10002"), jira.resources.Role), | ||
(url_test_case("plugin-resource/4.5/json/getMyObject"), jira.resources.UnknownResource), | ||
(url_test_case("group?groupname=bla"), jira.resources.Group), | ||
(url_test_case("user?username=bla"), jira.resources.User), # Jira Server / Data Center | ||
(url_test_case("user?accountId=bla"), jira.resources.User), # Jira Cloud | ||
], | ||
# fmt: on | ||
ids=[ | ||
"issue", | ||
"project", | ||
"role", | ||
"unknown_resource", | ||
"group", | ||
"user", | ||
"user_cloud", | ||
], | ||
) | ||
def test_cls_for_resource(self, example_url, expected_class): | ||
"""Test the regex recognizes the right class for a given URL.""" | ||
assert jira.resources.cls_for_resource(example_url) == expected_class |
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