def test_action_with_variables(self): """Test variables in action command""" cmd = 'echo %([ "%VAR1" != "" ] && echo "-x %VAR1")' action = Action("start", command=cmd) service = Service("TEST") service.add_actions(action) service.add_var("VAR1", "foo") action.run() self.assertEqual(action.worker.command, "echo -x foo")
def test_action_with_variables(self): """Test variables in action command""" cmd = 'echo %([ "%VAR1" != "" ] && echo "-x %VAR1")' action = Action('start', command=cmd) service = Service('TEST') service.add_actions(action) service.add_var('VAR1', 'foo') service.resolve_all() action.run() self.assertEqual(action.worker.command, 'echo -x foo')
def test_action_with_variables(self): """Test variables in action command""" cmd = 'echo %([ "%VAR1" != "" ] && echo "-x %VAR1")' action = Action('start', command=cmd) service = Service('TEST') service.add_actions(action) service.add_var('VAR1', 'foo') service.resolve_all() action.run() self.assertEqual(action.worker.command, 'echo -x foo')
def test_resolve_all(self): """Test variable resolution in resolve_all()""" srv = Service('svc1') srv.add_var('label', "I am a service") srv.fromdict({ 'desc': "%label", 'actions': { 'start': { 'cmd': 'service foo %ACTION' }, } }) srv.resolve_all() self.assertEqual(srv.desc, "I am a service") self.assertEqual(srv._actions['start'].command, "service foo start")
def test_resolve_all(self): """Test variable resolution in resolve_all()""" srv = Service('svc1') srv.add_var('label', "I am a service") srv.fromdict({ 'desc': "%label", 'actions': { 'start': { 'cmd': 'service foo %ACTION' }, } }) srv.resolve_all() self.assertEqual(srv.desc, "I am a service") self.assertEqual(srv._actions['start'].command, "service foo start")