1import json 2from mock import patch 3 4import jenkins 5from tests.jobs.base import JenkinsJobsTestBase 6 7 8class JenkinsJobsCountTest(JenkinsJobsTestBase): 9 10 @patch.object(jenkins.Jenkins, 'jenkins_open') 11 def test_simple(self, jenkins_mock): 12 jobs = [ 13 {u'url': u'http://localhost:8080/job/guava/', u'color': u'notbuilt', u'name': u'guava'}, 14 {u'url': u'http://localhost:8080/job/kiwi/', u'color': u'blue', u'name': u'kiwi'}, 15 {u'url': u'http://localhost:8080/job/lemon/', u'color': u'red', u'name': u'lemon'} 16 ] 17 job_info_to_return = {u'jobs': jobs} 18 jenkins_mock.return_value = json.dumps(job_info_to_return) 19 self.assertEqual(self.j.jobs_count(), 3) 20 self._check_requests(jenkins_mock.call_args_list) 21