Test requested URLs in test_getall
This would've caught that the info parameter is ignored in get_info and I'm going to refactor/improve get_all_jobs so I need stricter tests anyway. Also, this makes test_unsafe_chars useful. Before it was a totally meaningless test that didn't test anything at all. :-( (Actually the get_info problem was caught by this test, but I'm committing the fix first to not break git bisect.) Change-Id: Ifd06bbbd9969a2739322e36ae83f521490a6eaa0
This commit is contained in:
parent
afa1e05e74
commit
b1564e94b5
@ -43,3 +43,9 @@ class JenkinsTestBase(TestWithScenarios, unittest.TestCase):
|
||||
|
||||
for req in requests:
|
||||
req[0][0].prepare()
|
||||
|
||||
def got_request_urls(self, mock):
|
||||
return [
|
||||
call[0][0].url.split('?')[0]
|
||||
for call in mock.call_args_list
|
||||
]
|
||||
|
@ -23,6 +23,13 @@ class JenkinsGetAllJobsTest(JenkinsGetJobsTestBase):
|
||||
got_fullnames = [job[u"fullname"] for job in jobs_info]
|
||||
self.assertEqual(expected_fullnames, got_fullnames)
|
||||
|
||||
expected_request_urls = [
|
||||
self.make_url('api/json'),
|
||||
self.make_url('job/my_folder1/api/json')
|
||||
]
|
||||
self.assertEqual(expected_request_urls,
|
||||
self.got_request_urls(jenkins_mock))
|
||||
|
||||
@patch.object(jenkins.Jenkins, 'jenkins_open')
|
||||
def test_multi_level(self, jenkins_mock):
|
||||
response = build_jobs_list_responses(
|
||||
@ -44,6 +51,14 @@ class JenkinsGetAllJobsTest(JenkinsGetJobsTestBase):
|
||||
for job in jobs_info
|
||||
if job['name'] == u"my_job1"]))
|
||||
|
||||
expected_request_urls = [
|
||||
self.make_url('api/json'),
|
||||
self.make_url('job/my_folder1/api/json'),
|
||||
self.make_url('job/my_folder1/job/my_folder2/api/json')
|
||||
]
|
||||
self.assertEqual(expected_request_urls,
|
||||
self.got_request_urls(jenkins_mock))
|
||||
|
||||
@patch.object(jenkins.Jenkins, 'jenkins_open')
|
||||
def test_folders_depth(self, jenkins_mock):
|
||||
response = build_jobs_list_responses(
|
||||
@ -60,6 +75,13 @@ class JenkinsGetAllJobsTest(JenkinsGetJobsTestBase):
|
||||
got_fullnames = [job[u"fullname"] for job in jobs_info]
|
||||
self.assertEqual(expected_fullnames, got_fullnames)
|
||||
|
||||
expected_request_urls = [
|
||||
self.make_url('api/json'),
|
||||
self.make_url('job/my_folder1/api/json')
|
||||
]
|
||||
self.assertEqual(expected_request_urls,
|
||||
self.got_request_urls(jenkins_mock))
|
||||
|
||||
@patch.object(jenkins.Jenkins, 'jenkins_open')
|
||||
def test_unsafe_chars(self, jenkins_mock):
|
||||
response = build_jobs_list_responses(
|
||||
@ -76,3 +98,11 @@ class JenkinsGetAllJobsTest(JenkinsGetJobsTestBase):
|
||||
self.assertEqual(len(expected_fullnames), len(jobs_info))
|
||||
got_fullnames = [job[u"fullname"] for job in jobs_info]
|
||||
self.assertEqual(expected_fullnames, got_fullnames)
|
||||
|
||||
expected_request_urls = [
|
||||
self.make_url('api/json'),
|
||||
self.make_url('job/my_folder1/api/json'),
|
||||
self.make_url('job/my_folder1/job/my%20spaced%20folder/api/json')
|
||||
]
|
||||
self.assertEqual(expected_request_urls,
|
||||
self.got_request_urls(jenkins_mock))
|
||||
|
Loading…
Reference in New Issue
Block a user