Exemplo n.º 1
0
    def test_containerize_decorator_two(self, mocked_signal, mocked_option,
                                        mocked_runner, mocked_builder,
                                        mocked_shutil, mocked_os):
        '''Test Containerize decorator in case of
            is_in_docker_container return False
        '''
        mocked_os.getenv.return_value = 'false'

        # Input parameters
        def test_func():
            pass

        containerize.Containerize()(test_func)()

        # Assert for calls in constructor
        self.assertEqual(mocked_option.load.call_count, 2)
        self.assertEqual(mocked_builder.select.call_count, 1)
        self.assertEqual(mocked_runner.select.call_count, 1)

        # Assert for calls in __call__ section
        self.assertEqual(mocked_os.getenv.call_count, 1)
        self.assertEqual(mocked_signal.signal.call_count, 1)
        self.assertEqual(mocked_runner.select().run.call_count, 1)
        self.assertEqual(mocked_runner.select().logs.call_count, 1)
        self.assertEqual(mocked_builder.select().build.call_count, 1)
Exemplo n.º 2
0
    def test_containerize_decorator_one(self, mocked_option, mocked_runner,
                                        mocked_builder, mocked_os):
        '''Test Containerize decorator in case of
            is_in_docker_container return True
        '''
        mocked_os.getenv.return_value = 'true'
        expected_value = FunctionType

        # Input parameters
        def test_func():
            pass

        actual_value = containerize.Containerize()(test_func)

        self.assertEqual(type(actual_value), expected_value)