def test_should_create_working_directory_in_configured_temporary_directory(self, mock_makedirs, mock_mkdtemp, mock_exists):

        mock_config_rpm_maker = self.create_mock_config_rpm_maker()

        ConfigRpmMaker._prepare_work_dir(mock_config_rpm_maker)

        mock_mkdtemp.assert_called_with(prefix='yadt-config-rpm-maker.', suffix='.4852', dir='temporary directory')
    def test_should_not_create_any_directory_when_all_directories_exist(self, mock_makedirs, mock_mkdtemp, mock_exists):

        mock_config_rpm_maker = self.create_mock_config_rpm_maker()
        mock_exists.return_value = True

        ConfigRpmMaker._prepare_work_dir(mock_config_rpm_maker)

        self.assert_mock_never_called(mock_makedirs)
    def test_should_create_SOURCES_directory_when_it_does_not_exist(self, mock_makedirs, mock_mkdtemp, mock_exists):

        mock_config_rpm_maker = self.create_mock_config_rpm_maker()
        mock_exists.return_value = False
        mock_mkdtemp.return_value = 'working-directory'

        ConfigRpmMaker._prepare_work_dir(mock_config_rpm_maker)

        mock_makedirs.assert_any_call('working-directory/rpmbuild/SOURCES')
    def test_should_not_create_any_directory_when_all_directories_exist(
            self, mock_makedirs, mock_mkdtemp, mock_exists):

        mock_config_rpm_maker = self.create_mock_config_rpm_maker()
        mock_exists.return_value = True

        ConfigRpmMaker._prepare_work_dir(mock_config_rpm_maker)

        self.assert_mock_never_called(mock_makedirs)
    def test_should_create_SOURCES_directory_when_it_does_not_exist(
            self, mock_makedirs, mock_mkdtemp, mock_exists):

        mock_config_rpm_maker = self.create_mock_config_rpm_maker()
        mock_exists.return_value = False
        mock_mkdtemp.return_value = 'working-directory'

        ConfigRpmMaker._prepare_work_dir(mock_config_rpm_maker)

        mock_makedirs.assert_any_call('working-directory/rpmbuild/SOURCES')
    def test_should_create_working_directory_in_configured_temporary_directory(
            self, mock_makedirs, mock_mkdtemp, mock_exists):

        mock_config_rpm_maker = self.create_mock_config_rpm_maker()

        ConfigRpmMaker._prepare_work_dir(mock_config_rpm_maker)

        mock_mkdtemp.assert_called_with(prefix='yadt-config-rpm-maker.',
                                        suffix='.4852',
                                        dir='temporary directory')