Exemple #1
0
class TestCleanCommand(UnitTest):
    def setUp(self):
        self.setUpWithTmpBuildDir()
        self.command = CleanCommand(self.config)

    @mock.patch('shutil.rmtree', side_effect=empty_fn)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.logger.warning',
                side_effect=empty_fn)
    def test_clean(self, mock_logger_warning, mock_exists, mock_rmtree):
        self.command.run()

        mock_exists.assert_called_with(ANY)
        mock_rmtree.assert_called_with(ANY)
        mock_logger_warning.assert_not_called()

    @mock.patch('shutil.rmtree', side_effect=no_file_dir)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.logger.warning',
                side_effect=empty_fn)
    def test_no_file_dir(self, mock_logger_warning, mock_exists, mock_rmtree):
        self.command.run()

        mock_exists.assert_called_with(ANY)
        mock_rmtree.assert_called_with(ANY)
        mock_logger_warning.assert_not_called()

    @mock.patch('shutil.rmtree', side_effect=no_file_temp)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.logger.warning',
                side_effect=empty_fn)
    def test_no_file_temp(self, mock_logger_warning, mock_exists, mock_rmtree):
        self.command.run()

        mock_exists.assert_called_with(ANY)
        mock_rmtree.assert_called_with(ANY)
        mock_logger_warning.assert_not_called()

    @mock.patch('shutil.rmtree', side_effect=dir_exception)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.logger.warning',
                side_effect=empty_fn)
    def test_dir_exception(self, mock_logger_warning, mock_exists,
                           mock_rmtree):
        self.command.run()

        mock_exists.assert_called_with(ANY)
        mock_rmtree.assert_called_with(ANY)
        mock_logger_warning.assert_called_with(ANY)

    @mock.patch('shutil.rmtree', side_effect=temp_exception)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.logger.warning',
                side_effect=empty_fn)
    def test_temp_exception(self, mock_logger_warning, mock_exists,
                            mock_rmtree):
        self.command.run()

        mock_exists.assert_called_with(ANY)
        mock_rmtree.assert_called_with(ANY)
Exemple #2
0
class TestCleanCommand(TestCase):
    def setUp(self):
        self.config = ConfigMock({})
        self.command = CleanCommand(self.config)

    @mock.patch('shutil.rmtree', side_effect=empty_fn)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.print_warning', side_effect=empty_fn)
    def test_clean(self, mock_print_warning, mock_exists, mock_rmtree):
        self.command.run()

        mock_exists.assert_called()
        mock_rmtree.assert_called()
        mock_print_warning.assert_not_called()

    @mock.patch('shutil.rmtree', side_effect=no_file_dir)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.print_warning', side_effect=empty_fn)
    def test_no_file_dir(self, mock_print_warning, mock_exists, mock_rmtree):
        self.command.run()

        mock_exists.assert_called()
        mock_rmtree.assert_called()
        mock_print_warning.assert_not_called()

    @mock.patch('shutil.rmtree', side_effect=no_file_temp)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.print_warning', side_effect=empty_fn)
    def test_no_file_temp(self, mock_print_warning, mock_exists, mock_rmtree):
        self.command.run()

        mock_exists.assert_called()
        mock_rmtree.assert_called()
        mock_print_warning.assert_not_called()

    @mock.patch('shutil.rmtree', side_effect=dir_exception)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.print_warning', side_effect=empty_fn)
    def test_dir_exception(self, mock_print_warning, mock_exists, mock_rmtree):
        self.command.run()

        mock_exists.assert_called()
        mock_rmtree.assert_called()
        mock_print_warning.assert_called()

    @mock.patch('shutil.rmtree', side_effect=temp_exception)
    @mock.patch('os.path.exists', side_effect=true_fn)
    @mock.patch('clickable.commands.clean.print_warning', side_effect=empty_fn)
    def test_temp_exception(self, mock_print_warning, mock_exists,
                            mock_rmtree):
        self.command.run()

        mock_exists.assert_called()
        mock_rmtree.assert_called()
        mock_print_warning.assert_called()
Exemple #3
0
 def setUp(self):
     self.config = ConfigMock()
     self.config.container = Container(self.config)
     self.command = CleanCommand(self.config)
Exemple #4
0
 def setUp(self):
     self.config = ConfigMock({})
     self.command = CleanCommand(self.config)
Exemple #5
0
 def setUp(self):
     self.setUpWithTmpBuildDir()
     self.command = CleanCommand(self.config)