Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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"
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'), Resource)
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,
)
def test_pickling_resource(self):
resource = self.jira.find('issue/{0}',
self.test_manager.project_b_issue1)
pickled = pickle.dumps(resource.raw)
unpickled = pickle.loads(pickled)
cls = cls_for_resource(unpickled['self'])
unpickled_instance = cls(self.jira._options, self.jira._session, raw=pickle.loads(pickled))
self.assertEqual(resource.key, unpickled_instance.key)
self.assertTrue(resource == unpickled_instance)
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'), Resource)
def test_pickling_resource(self):
resource = self.jira.find("issue/{0}", self.test_manager.project_b_issue1)
pickled = pickle.dumps(resource.raw)
unpickled = pickle.loads(pickled)
cls = cls_for_resource(unpickled["self"])
unpickled_instance = cls(
self.jira._options, self.jira._session, raw=pickle.loads(pickled)
)
self.assertEqual(resource.key, unpickled_instance.key)
self.assertTrue(resource == unpickled_instance)
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'), Resource)
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"
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'), Resource)
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"