Ejemplo n.º 1
0
    def __init__(self):
        self.sub_proc = SubProc()
        self.docker = Docker(self.sub_proc)
        self.runner = Runner(self.docker)
        self.file_wrapper = FileWrapper()
        self.bc_module = BcModule(self.docker, self.runner, self.file_wrapper)
        self.git = Git(self.sub_proc)
        self.ui = Ui()

        self.tools = [
            help.Help(self.bc_module),
            update.Update(self.docker),
            version.Version(self.docker),
            ghrn.Ghrn(self.docker),
            docs.Docs(self.docker),
        ]

        self.config_reader = ConfigReader(self.file_wrapper, self.bc_module,
                                          self.tools)
Ejemplo n.º 2
0
 def setUp(self):
     self.sut = SubProc()
Ejemplo n.º 3
0
class SubprocTest(unittest.TestCase):

    def setUp(self):
        self.sut = SubProc()

    def test_that_call_passes_args_on(self):
        # Fixture
        subprocess.call = MagicMock(return_value=47)

        # Test
        actual = self.sut.call(1, "string", name="value")

        # Assert
        subprocess.call.assert_called_with(1, "string", name="value")
        self.assertEqual(47, actual)

    def test_that_call_handles_exception(self):
        # Fixture
        subprocess.call = MagicMock(
                side_effect=subprocess.CalledProcessError(
                        17, 'cmd', b'output'))

        # Test
        # Assert
        with self.assertRaises(ToolbeltException):
            self.sut.call()

    def test_that_check_call_passes_args_on(self):
        # Fixture
        subprocess.check_call = MagicMock(return_value=b'Some string')

        # Test
        actual = self.sut.check_call(1, "string", name="value")

        # Assert
        subprocess.check_call.assert_called_with(1, "string", name="value")

    def test_that_check_call_handles_exception(self):
        # Fixture
        subprocess.check_call = MagicMock(
                side_effect=subprocess.CalledProcessError(
                        17, 'message', b'output'))

        # Test
        # Assert
        with self.assertRaises(ToolbeltException):
            self.sut.check_call()

    def test_that_check_output_passes_args_on(self):
        # Fixture
        subprocess.check_output = MagicMock(return_value=b'Some string')

        # Test
        actual = self.sut.check_output(1, "string", name="value")

        # Assert
        subprocess.check_output.assert_called_with(1, "string", name="value")

    def test_that_check_output_handles_exception(self):
        # Fixture
        subprocess.check_output = MagicMock(
                side_effect=subprocess.CalledProcessError(
                        17, 'message', b'output'))

        # Test
        # Assert
        with self.assertRaises(ToolbeltException):
            self.sut.check_output()

    def test_that_output_is_converted_to_utf8(self):
        # Fixture
        subprocess.check_output = MagicMock(return_value=b'Some string')

        # Test
        actual = self.sut.check_output()

        # Assert
        self.assertEqual('Some string', actual)
Ejemplo n.º 4
0
 def __init__(self, sub_proc=SubProc()):
     self._sub_proc = sub_proc
     self.db_restart_wait_time = 1
Ejemplo n.º 5
0
 def setUp(self):
     self.sut = SubProc()
Ejemplo n.º 6
0
class SubprocTest(unittest.TestCase):

    def setUp(self):
        self.sut = SubProc()

    def test_that_call_passes_args_on(self):
        # Fixture
        subprocess.call = MagicMock(return_value=47)

        # Test
        actual = self.sut.call(1, "string", name="value")

        # Assert
        subprocess.call.assert_called_with(1, "string", name="value")
        self.assertEqual(47, actual)

    def test_that_call_handles_exception(self):
        # Fixture
        subprocess.call = MagicMock(
                side_effect=subprocess.CalledProcessError(
                        17, 'cmd', b'output'))

        # Test
        # Assert
        with self.assertRaises(ToolbeltException):
            self.sut.call()

    def test_that_check_call_passes_args_on(self):
        # Fixture
        subprocess.check_call = MagicMock(return_value=b'Some string')

        # Test
        self.sut.check_call(1, "string", name="value")

        # Assert
        subprocess.check_call.assert_called_with(1, "string", name="value")

    def test_that_check_call_handles_exception(self):
        # Fixture
        subprocess.check_call = MagicMock(
                side_effect=subprocess.CalledProcessError(
                        17, 'message', b'output'))

        # Test
        # Assert
        with self.assertRaises(ToolbeltException):
            self.sut.check_call()

    def test_that_check_output_passes_args_on(self):
        # Fixture
        subprocess.check_output = MagicMock(return_value=b'Some string')

        # Test
        self.sut.check_output(1, "string", name="value")

        # Assert
        subprocess.check_output.assert_called_with(1, "string", name="value")

    def test_that_check_output_handles_exception(self):
        # Fixture
        subprocess.check_output = MagicMock(
                side_effect=subprocess.CalledProcessError(
                        17, 'message', b'output'))

        # Test
        # Assert
        with self.assertRaises(ToolbeltException):
            self.sut.check_output()

    def test_that_output_is_converted_to_utf8(self):
        # Fixture
        subprocess.check_output = MagicMock(return_value=b'Some string')

        # Test
        actual = self.sut.check_output()

        # Assert
        self.assertEqual('Some string', actual)
Ejemplo n.º 7
0
 def __init__(self, subproc=SubProc()):
     self.subproc = subproc