Permalink
Browse files

Add test for wait for build

  • Loading branch information...
1 parent 402dc17 commit 10c9c1daf9a1614f2f48be7264e79cb4c7d02d69 Carles Barrobés committed May 12, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 autojenkins/tests/test_unit_jobs.py
@@ -144,7 +144,7 @@ def test_post_methods_with_jobname(self, case, requests, Template):
@patch('autojenkins.jobs.time')
@patch('autojenkins.jobs.Jenkins.last_result')
@patch('autojenkins.jobs.Jenkins.wait_for_build')
- def test_build_wait(self, wait_for_build, last_result, time, requests,
+ def test_build_with_wait(self, wait_for_build, last_result, time, requests,
Template):
"""Test building a job synchronously"""
requests.post.return_value = mock_response(status=302)
@@ -157,6 +157,16 @@ def test_build_wait(self, wait_for_build, last_result, time, requests,
last_result.assert_called_once_with('name')
time.sleep.assert_called_once_with(10)
+ @patch('autojenkins.jobs.time')
+ @patch('autojenkins.jobs.sys')
+ @patch('autojenkins.jobs.Jenkins.is_building')
+ def test_wait_for_build(self, is_building, sys, time, requests, Template):
+ is_building.side_effect = [True, True, False]
+ self.jenkins.wait_for_build('name')
+ self.assertEqual(3, is_building.call_count)
+ self.assertEqual(2, time.sleep.call_count)
+ self.assertEqual(((3,), {}), time.sleep.call_args)
+
def test_404_raises_http_not_found(self, requests, Template):
http404_response = Mock()
http404_response.status_code = 404

0 comments on commit 10c9c1d

Please sign in to comment.