def test_no_kwargs(self):
     runnable = Runnable(kind='package', uri=None)
     runner = PackageRunner()
     status = runner.run(runnable)
     messages = []
     while True:
         try:
             messages.append(next(status))
         except StopIteration:
             break
     result = 'error'
     self.assertIn(result, messages[-1]['result'])
     stderr = b'Package name should be passed as kwargs'
     self.assertIn(stderr, messages[-2]['log'])
 def test_wrong_action(self):
     runnable = Runnable(kind='package', uri=None, **{'action': 'foo'})
     runner = PackageRunner()
     status = runner.run(runnable)
     messages = []
     while True:
         try:
             messages.append(next(status))
         except StopIteration:
             break
     result = 'error'
     self.assertIn(result, messages[-1]['result'])
     stderr = b"Invalid action foo. Use one of 'install', 'check' or 'remove'"
     self.assertIn(stderr, messages[-2]['log'])
Beispiel #3
0
 def test_wrong_action(self):
     runnable = Runnable(kind="package", uri=None, **{"action": "foo"})
     runner = PackageRunner()
     status = runner.run(runnable)
     messages = []
     while True:
         try:
             messages.append(next(status))
         except StopIteration:
             break
     result = "error"
     self.assertIn(result, messages[-1]["result"])
     stderr = b"Invalid action foo. Use one of 'install', 'check' or 'remove'"
     self.assertIn(stderr, messages[-2]["log"])
Beispiel #4
0
 def test_no_kwargs(self):
     runnable = Runnable(kind="package", uri=None)
     runner = PackageRunner()
     status = runner.run(runnable)
     messages = []
     while True:
         try:
             messages.append(next(status))
         except StopIteration:
             break
     result = "error"
     self.assertIn(result, messages[-1]["result"])
     stderr = b"Package name should be passed as kwargs"
     self.assertIn(stderr, messages[-2]["log"])
Beispiel #5
0
    def test_already_installed(self):

        self.mock_sm.return_value.check_installed = lambda check_installed: True
        runnable = Runnable(
            kind="package", uri=None, **{"action": "install", "name": "foo"}
        )
        runner = PackageRunner()
        status = runner.run(runnable)
        messages = []
        while True:
            try:
                messages.append(next(status))
            except StopIteration:
                break
        self.assertEqual(messages[-1]["result"], "pass")
        stdout = b"Package foo already installed"
        self.assertIn(stdout, messages[-3]["log"])
Beispiel #6
0
    def test_fail_check(self):

        self.mock_sm.return_value.check_installed = lambda check_installed: False
        runnable = Runnable(
            kind="package", uri=None, **{"action": "check", "name": "foo"}
        )
        runner = PackageRunner()
        status = runner.run(runnable)
        messages = []
        while True:
            try:
                messages.append(next(status))
            except StopIteration:
                break
        self.assertEqual(messages[-1]["result"], "error")
        stderr = b"Package foo not installed"
        self.assertIn(stderr, messages[-2]["log"])
    def test_already_installed(self):

        self.mock_sm.return_value.check_installed = lambda check_installed: True
        runnable = Runnable(kind='package',
                            uri=None,
                            **{
                                'action': 'install',
                                'name': 'foo'
                            })
        runner = PackageRunner()
        status = runner.run(runnable)
        messages = []
        while True:
            try:
                messages.append(next(status))
            except StopIteration:
                break
        self.assertEqual(messages[-1]['result'], 'pass')
        stdout = b'Package foo already installed'
        self.assertIn(stdout, messages[-3]['log'])
    def test_fail_check(self):

        self.mock_sm.return_value.check_installed = lambda check_installed: False
        runnable = Runnable(kind='package',
                            uri=None,
                            **{
                                'action': 'check',
                                'name': 'foo'
                            })
        runner = PackageRunner()
        status = runner.run(runnable)
        messages = []
        while True:
            try:
                messages.append(next(status))
            except StopIteration:
                break
        self.assertEqual(messages[-1]['result'], 'error')
        stderr = b'Package foo not installed'
        self.assertIn(stderr, messages[-2]['log'])