Exemplo n.º 1
0
    def test_execute_invalid_command(self):
        """If the given command could not be found for the given project, return an error tuple."""
        shove = Shove({"myproject": path("test_project")}, Mock())
        order = Order(project="myproject", command="foo", log_key=5, log_queue="asdf")

        procfile_path = path("test_project", "bin", "commands.procfile")
        eq_(shove.execute(order), (1, "No command `foo` found in {0}".format(procfile_path)))
Exemplo n.º 2
0
    def test_execute_invalid_command(self):
        """If the given command could not be found for the given project, return an error tuple."""
        shove = Shove({'myproject': path('test_project')})
        order = Order(project='myproject', command='foo', log_key=5, log_queue='asdf')

        procfile_path = path('test_project', 'bin', 'commands.procfile')
        eq_(shove.execute(order), (1, 'No command `foo` found in {0}'.format(procfile_path)))
Exemplo n.º 3
0
    def test_process_order_invalid(self):
        """If parse_order returns None, do not execute the order."""
        shove = Shove({})
        shove.parse_order = Mock(return_value=None)
        shove.execute = Mock()

        eq_(shove.process_order('{"project": "asdf"}'), None)
        ok_(not shove.execute.called)
    def test_process_order_invalid(self):
        """If parse_order returns None, do not execute the order."""
        shove = Shove({})
        shove.parse_order = Mock(return_value=None)
        shove.execute = Mock()

        eq_(shove.process_order('{"project": "asdf"}'), None)
        ok_(not shove.execute.called)
 def test_execute_invalid_project(self):
     """If no project with the given name is found, return an error tuple."""
     shove = Shove({'myproject': '/foo/bar/baz'})
     order = Order(project='nonexistant',
                   command='foo',
                   log_key=5,
                   log_queue='asdf')
     eq_(shove.execute(order), (1, 'No project `nonexistant` found.'))
 def test_execute_no_procfile(self):
     """If no procfile is found for the given project, return an error tuple."""
     shove = Shove({'myproject': path('nonexistant')})
     order = Order(project='myproject',
                   command='foo',
                   log_key=5,
                   log_queue='asdf')
     eq_(shove.execute(order),
         (1, CONTAINS('Error loading procfile for project `myproject`')))
    def test_execute_invalid_command(self):
        """If the given command could not be found for the given project, return an error tuple."""
        shove = Shove({'myproject': path('test_project')})
        order = Order(project='myproject',
                      command='foo',
                      log_key=5,
                      log_queue='asdf')

        procfile_path = path('test_project', 'bin', 'commands.procfile')
        eq_(shove.execute(order),
            (1, 'No command `foo` found in {0}'.format(procfile_path)))
Exemplo n.º 8
0
    def test_process_order_valid(self):
        """If parse_order returns a valid order, execute it and send logs back to Captain."""
        shove = Shove({}, Mock())
        order = Order(project="asdf", command="qwer", log_key=23, log_queue="zxcv")
        shove.parse_order = Mock(return_value=order)
        shove.execute = Mock(return_value=(0, "output"))

        shove.process_order('{"project": "asdf"}')
        shove.execute.assert_called_with(order)
        shove.adapter.send_log.assert_called_with(
            "zxcv", JSON({"version": "1.0", "log_key": 23, "return_code": 0, "output": "output"})
        )
Exemplo n.º 9
0
    def test_process_order_valid(self):
        """If parse_order returns a valid order, execute it and send logs back to Captain."""
        shove = Shove({})
        order = Order(project='asdf', command='qwer', log_key=23, log_queue='zxcv')
        shove.parse_order = Mock(return_value=order)
        shove.execute = Mock(return_value=(0, 'output'))

        eq_(shove.process_order('{"project": "asdf"}'), ('zxcv', JSON({
            'version': '1.0',
            'log_key': 23,
            'return_code': 0,
            'output': 'output'
        })))
        shove.execute.assert_called_with(order)
Exemplo n.º 10
0
    def test_execute_valid_order(self):
        shove = Shove({"myproject": path("test_project")}, Mock())
        order = Order(project="myproject", command="pwd", log_key=5, log_queue="asdf")

        with patch("shove.base.Popen") as Popen:
            p = Popen.return_value
            p.communicate.return_value = "command output", None
            p.returncode = 0

            return_code, output = shove.execute(order)

        Popen.assert_called_with(["pwd"], cwd=path("test_project"), stdout=PIPE, stderr=STDOUT)
        p.communicate.assert_called_with()
        eq_(return_code, 0)
        eq_(output, "command output")
Exemplo n.º 11
0
    def test_execute_valid_order(self):
        shove = Shove({'myproject': path('test_project')})
        order = Order(project='myproject', command='pwd', log_key=5, log_queue='asdf')

        with patch('shove.base.Popen') as Popen:
            p = Popen.return_value
            p.communicate.return_value = 'command output', None
            p.returncode = 0

            return_code, output = shove.execute(order)

        Popen.assert_called_with(['pwd'], cwd=path('test_project'), stdout=PIPE, stderr=STDOUT)
        p.communicate.assert_called_with()
        eq_(return_code, 0)
        eq_(output, 'command output')
    def test_process_order_valid(self):
        """If parse_order returns a valid order, execute it and send logs back to Captain."""
        shove = Shove({})
        order = Order(project='asdf',
                      command='qwer',
                      log_key=23,
                      log_queue='zxcv')
        shove.parse_order = Mock(return_value=order)
        shove.execute = Mock(return_value=(0, 'output'))

        eq_(shove.process_order('{"project": "asdf"}'),
            ('zxcv',
             JSON({
                 'version': '1.0',
                 'log_key': 23,
                 'return_code': 0,
                 'output': 'output'
             })))
        shove.execute.assert_called_with(order)
    def test_execute_valid_order(self):
        shove = Shove({'myproject': path('test_project')})
        order = Order(project='myproject',
                      command='pwd',
                      log_key=5,
                      log_queue='asdf')

        with patch('shove.base.Popen') as Popen:
            p = Popen.return_value
            p.communicate.return_value = 'command output', None
            p.returncode = 0

            return_code, output = shove.execute(order)

        Popen.assert_called_with(['pwd'],
                                 cwd=path('test_project'),
                                 stdout=PIPE,
                                 stderr=STDOUT)
        p.communicate.assert_called_with()
        eq_(return_code, 0)
        eq_(output, 'command output')
Exemplo n.º 14
0
 def test_execute_no_procfile(self):
     """If no procfile is found for the given project, return an error tuple."""
     shove = Shove({"myproject": path("nonexistant")}, Mock())
     order = Order(project="myproject", command="foo", log_key=5, log_queue="asdf")
     eq_(shove.execute(order), (1, CONTAINS("Error loading procfile for project `myproject`")))
Exemplo n.º 15
0
 def test_execute_invalid_project(self):
     """If no project with the given name is found, return an error tuple."""
     shove = Shove({"myproject": "/foo/bar/baz"}, Mock())
     order = Order(project="nonexistant", command="foo", log_key=5, log_queue="asdf")
     eq_(shove.execute(order), (1, "No project `nonexistant` found."))
Exemplo n.º 16
0
 def test_execute_invalid_project(self):
     """If no project with the given name is found, return an error tuple."""
     shove = Shove({'myproject': '/foo/bar/baz'})
     order = Order(project='nonexistant', command='foo', log_key=5, log_queue='asdf')
     eq_(shove.execute(order), (1, 'No project `nonexistant` found.'))
Exemplo n.º 17
0
 def test_execute_no_procfile(self):
     """If no procfile is found for the given project, return an error tuple."""
     shove = Shove({'myproject': path('nonexistant')})
     order = Order(project='myproject', command='foo', log_key=5, log_queue='asdf')
     eq_(shove.execute(order), (1, CONTAINS('Error loading procfile for project `myproject`')))