Example #1
0
    def setUp(self):
        self.wrapper = Wrapper(bash_location='/bin/sh')
        self.script = TestableScript(script=dedent("""\
              #!/bin/sh
              #PBS -q debug
              #PBS -l nodes=1:ppn=1

              echo "hello world"
              echo "this is to stderr" >&2
              """),
                                     status=Status.success,
                                     stdout='hello world',
                                     stderr='this is to stderr')

        self.script_fd = NamedTemporaryFile()
        self.script.write(self.script_fd)
        self.script_fd.seek(0)
        self.script_path = self.script_fd.name
Example #2
0
class TestWrapper(TestCase):

    def setUp(self):
        self.wrapper = Wrapper(bash_location='/bin/sh')
        self.script  = TestableScript(
            script=dedent("""\
              #!/bin/sh
              #PBS -q debug
              #PBS -l nodes=1:ppn=1

              echo "hello world"
              echo "this is to stderr" >&2
              """),
            status=Status.success,
            stdout='hello world',
            stderr='this is to stderr')

        self.script_fd = NamedTemporaryFile()
        self.script.write(self.script_fd)
        self.script_fd.seek(0)
        self.script_path = self.script_fd.name

    def tearDown(self):
        self.script_fd.close()


    @property
    def wrapped(self):
        return self.wrapper.wrap(self.script_path)

    def test_wrap_works(self):
        "Wrapper should work"
        wrapped = self.wrapped
        self.assertIsNotNone(wrapped)

    def test_names(self):
        w = self.wrapped
        name = os.path.basename(self.script_path)
        self.assertEquals(w.entrypoint.name, name)
        self.assertEquals(w.wrapped.name, 'wrapped-{}'.format(name))

    def test_run(self):
        w = Worker()
        r = w(self.wrapped)
        self.assertEquals(r.status, self.script.status)
        self.assertEquals(r.stdout, self.script.stdout)
        self.assertEquals(r.stderr, self.script.stderr)
Example #3
0
class TestWrapper(TestCase):
    def setUp(self):
        self.wrapper = Wrapper(bash_location='/bin/sh')
        self.script = TestableScript(script=dedent("""\
              #!/bin/sh
              #PBS -q debug
              #PBS -l nodes=1:ppn=1

              echo "hello world"
              echo "this is to stderr" >&2
              """),
                                     status=Status.success,
                                     stdout='hello world',
                                     stderr='this is to stderr')

        self.script_fd = NamedTemporaryFile()
        self.script.write(self.script_fd)
        self.script_fd.seek(0)
        self.script_path = self.script_fd.name

    def tearDown(self):
        self.script_fd.close()

    @property
    def wrapped(self):
        return self.wrapper.wrap(self.script_path)

    def test_wrap_works(self):
        "Wrapper should work"
        wrapped = self.wrapped
        self.assertIsNotNone(wrapped)

    def test_names(self):
        w = self.wrapped
        name = os.path.basename(self.script_path)
        self.assertEquals(w.entrypoint.name, name)
        self.assertEquals(w.wrapped.name, 'wrapped-{}'.format(name))

    def test_run(self):
        w = Worker()
        r = w(self.wrapped)
        self.assertEquals(r.status, self.script.status)
        self.assertEquals(r.stdout, self.script.stdout)
        self.assertEquals(r.stderr, self.script.stderr)
Example #4
0
    def setUp(self):
        self.wrapper = Wrapper(bash_location='/bin/sh')
        self.script  = TestableScript(
            script=dedent("""\
              #!/bin/sh
              #PBS -q debug
              #PBS -l nodes=1:ppn=1

              echo "hello world"
              echo "this is to stderr" >&2
              """),
            status=Status.success,
            stdout='hello world',
            stderr='this is to stderr')

        self.script_fd = NamedTemporaryFile()
        self.script.write(self.script_fd)
        self.script_fd.seek(0)
        self.script_path = self.script_fd.name