def test_abject_failure(self): with patch('gaia_uplift.git.push') as push, \ patch('gaia_uplift.util.ask_yn') as ask_yn: preview = {'url': None, 'branches': {'master': ("a"*40, "b"*40) } } ask_yn.return_value = False push.side_effect = git.PushFailure with self.assertRaises(git.PushFailure): subject.push(None)
def test_no_push(self): with patch('gaia_uplift.git.push') as push, \ patch('gaia_uplift.util.ask_yn') as ask_yn: preview = {'url': None, 'branches': { 'master': ("a"*40, "b"*40) } } push.return_value = preview ask_yn.return_value = False self.assertEqual(None, subject.push(None))
def test_recovery(self): with patch('gaia_uplift.git.push') as push, \ patch('gaia_uplift.util.ask_yn') as ask_yn: ask_yn.return_value = True expected = {'url': None, 'branches': { 'master': ("a"*40, "b"*40) } } push.side_effect = [expected, git.PushFailure, expected] actual = subject.push(None) self.assertEqual(expected, actual)
def test_success(self): with patch('gaia_uplift.git.push') as push, \ patch('gaia_uplift.util.ask_yn') as ask_yn: ask_yn.return_value = True expected = {'url': None, 'branches': { 'master': ("a"*40, "b"*40) } } push.return_value = expected actual = subject.push(None) self.assertEqual(expected, actual)