def command(args): from sr.comp.raw_compstate import RawCompstate compstate = RawCompstate(args.compstate, local_only=False) hosts = deploy.get_deployments(compstate) deploy.require_no_changes(compstate) if not args.no_pull: with deploy.exit_on_exception(): compstate.pull_fast_forward() how_long, when = add_delay.command(args) if args.when != 'now': msg = "Confirm adding {0} delay at {1}".format(how_long, when) if not deploy.query_bool(msg, default_val=True): print("Leaving state with local modifications") exit() deploy.require_valid(compstate) with deploy.exit_on_exception(kind=RuntimeError): compstate.stage('schedule.yaml') msg = "Adding {0} delay at {1}".format(args.how_long, when) compstate.commit(msg) deploy.run_deployments(args, compstate, hosts)
def test_query_bool_no_default_other_then_y(mock_get_input): values = ['other', 'y'] mock_get_input.side_effect = lambda x: values.pop(0) res = query_bool('Question?') assert res == True assert mock_get_input.call_count == 2
def test_query_bool_no_default_other_then_y(self, mocked_get_input): res = query_bool('Question?') self.assertTrue(res) self.assertEqual(2, mocked_get_input.call_count)
def test_query_bool_no_default_n(self, _): res = query_bool('Question?') self.assertFalse(res)
def test_query_bool_no_default_y(self, _): res = query_bool('Question?') self.assertTrue(res)
def test_query_bool_False_other(self, _): res = query_bool('Question?', False) self.assertFalse(res)
def test_query_bool_False_y(self, _): res = query_bool('Question?', False) self.assertTrue(res)
def test_query_bool_True_other(self, _): res = query_bool('Question?', True) self.assertTrue(res)
def test_query_bool_True_n(self, _): res = query_bool('Question?', True) self.assertFalse(res)
def test_query_bool_no_default_n(): res = query_bool('Question?') assert res == False
def test_query_bool_no_default_y(): res = query_bool('Question?') assert res == True
def test_query_bool_False_other(): res = query_bool('Question?', False) assert res == False
def test_query_bool_False_y(): res = query_bool('Question?', False) assert res == True
def test_query_bool_True_other(): res = query_bool('Question?', True) assert res == True
def test_query_bool_True_n(): res = query_bool('Question?', True) assert res == False