def test_command_generation_for_chains(self): sultan = Sultan() self.assertEqual(str(sultan.touch( "/tmp/foo").and_().touch("/tmp/bar")), "touch /tmp/foo && touch /tmp/bar;") sultan = Sultan() self.assertEqual( str(sultan.yum( "install -y gcc").and_().ls("-lah /tmp").and_().find("/ -name gcc")), "yum install -y gcc && ls -lah /tmp && find / -name gcc;" )
def test_execution(self): sultan = Sultan() sultan.touch("/tmp/foo").run() response = sultan.ls("-1 /tmp/foo").run() self.assertEqual(response, ["/tmp/foo"])
def test_basic_command_chains(self): sultan = Sultan() self.assertEqual( str(sultan.touch("/tmp/foo").ls("-1 /tmp/foo").whoami()), "touch /tmp/foo; ls -1 /tmp/foo; whoami;")
def test_and(self): sultan = Sultan() self.assertEqual( str(sultan.touch("/tmp/foo").and_().touch("/tmp/bar")), "touch /tmp/foo && touch /tmp/bar;")
def test_or(self): sultan = Sultan() self.assertEqual(str(sultan.touch('/tmp/foobar').or_().echo('"Step Completed"')), "touch /tmp/foobar || echo \"Step Completed\";")