Ejemplo n.º 1
0
    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;"
        )
Ejemplo n.º 2
0
    def test_execution(self):

        sultan = Sultan()
        sultan.touch("/tmp/foo").run()
        response = sultan.ls("-1 /tmp/foo").run()
        self.assertEqual(response, ["/tmp/foo"])
Ejemplo n.º 3
0
    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;")
Ejemplo n.º 4
0
    def test_and(self):

        sultan = Sultan()
        self.assertEqual(
            str(sultan.touch("/tmp/foo").and_().touch("/tmp/bar")),
            "touch /tmp/foo && touch /tmp/bar;")
Ejemplo n.º 5
0
    def test_or(self):

        sultan = Sultan()
        self.assertEqual(str(sultan.touch('/tmp/foobar').or_().echo('"Step Completed"')),
                         "touch /tmp/foobar || echo \"Step Completed\";")