def test_should_not_delete_config_viewer_host_directory_when_change_set_contains_delete_of_a_file_in_host_directory(self, mock_rmtree, mock_exists):

        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = ['host/devweb01/host_specific_file']

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        self.assert_mock_never_called(mock_rmtree)
    def test_should_delete_config_viewer_host_directory_when_change_set_contains_delete_path_to_host_dir(self, mock_rmtree, mock_exists):

        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = ['host/devweb01']

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        mock_rmtree.assert_called_with('target/tmp/configviewer/hosts/devweb01')
    def test_should_pass_through_if_change_set_is_empty(self, mock_rmtree, mock_exists):

        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = []

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        mock_svn_service.get_deleted_paths.assert_called_with('42')
    def test_should_pass_through_if_change_set_is_empty(
            self, mock_rmtree, mock_exists):

        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = []

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        mock_svn_service.get_deleted_paths.assert_called_with('42')
Beispiel #5
0
def building_configuration_rpms_and_clean_host_directories(repository, revision):
    """ This function will start the process of building configuration rpms
        for the given configuration repository and the revision. """

    path_to_config = get_svn_path_to_config()
    svn_service = SvnService(base_url=repository, path_to_config=path_to_config)
    svn_service.log_change_set_meta_information(revision)
    ConfigRpmMaker(revision=revision, svn_service=svn_service).build()
    clean_up_deleted_hosts_data(svn_service, revision)
    def test_should_delete_config_viewer_host_directory_when_change_set_contains_delete_path_to_host_dir(
            self, mock_rmtree, mock_exists):

        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = ['host/devweb01']

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        mock_rmtree.assert_called_with(
            'target/tmp/configviewer/hosts/devweb01')
    def test_should_not_try_to_delete_directories_which_do_not_exist(self, mock_rmtree, mock_exists):

        mock_exists.return_value = False
        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = ['host/devweb01']

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        self.assert_mock_never_called(mock_rmtree)
        mock_exists.assert_any_call('target/tmp/configviewer/hosts/devweb01')
    def test_should_check_if_directory_exists_before_deleting_it(self, mock_rmtree, mock_exists):

        mock_exists.return_value = True
        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = ['host/devweb01']

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        mock_exists.assert_any_call('target/tmp/configviewer/hosts/devweb01')
        mock_rmtree.assert_any_call('target/tmp/configviewer/hosts/devweb01')
def building_configuration_rpms_and_clean_host_directories(
        repository, revision):
    """ This function will start the process of building configuration rpms
        for the given configuration repository and the revision. """

    path_to_config = get_svn_path_to_config()
    svn_service = SvnService(base_url=repository,
                             path_to_config=path_to_config)
    svn_service.log_change_set_meta_information(revision)
    ConfigRpmMaker(revision=revision, svn_service=svn_service).build()
    clean_up_deleted_hosts_data(svn_service, revision)
    def test_should_not_try_to_delete_directories_which_do_not_exist(
            self, mock_rmtree, mock_exists):

        mock_exists.return_value = False
        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = ['host/devweb01']

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        self.assert_mock_never_called(mock_rmtree)
        mock_exists.assert_any_call('target/tmp/configviewer/hosts/devweb01')
    def test_should_not_delete_config_viewer_host_directory_when_change_set_contains_delete_of_a_file_in_host_directory(
            self, mock_rmtree, mock_exists):

        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = [
            'host/devweb01/host_specific_file'
        ]

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        self.assert_mock_never_called(mock_rmtree)
    def test_should_check_if_directory_exists_before_deleting_it(
            self, mock_rmtree, mock_exists):

        mock_exists.return_value = True
        mock_svn_service = Mock(SvnService)
        mock_svn_service.get_deleted_paths.return_value = ['host/devweb01']

        clean_up_deleted_hosts_data(mock_svn_service, '42')

        mock_exists.assert_any_call('target/tmp/configviewer/hosts/devweb01')
        mock_rmtree.assert_any_call('target/tmp/configviewer/hosts/devweb01')
    def test_should_delete_config_viewer_host_directories_when_directories_have_been_deleted_in_repository(self):

        svn_service = SvnService(base_url=self.repo_url, path_to_config=get_svn_path_to_config())
        ConfigRpmMaker('1', svn_service).build()

        if call('svn delete -q -m "deleting host tuvweb01 and devweb01" {0}/config/host/devweb01 {0}/config/host/tuvweb01'.format(self.repo_url), shell=True):
            raise IntegrationTestException('Could not delete test data.')

        clean_up_deleted_hosts_data(svn_service, '3')

        self.assert_path_exists(build_config_viewer_host_directory('berweb01'))
        self.assert_path_does_not_exist(build_config_viewer_host_directory('devweb01'))
        self.assert_path_does_not_exist(build_config_viewer_host_directory('tuvweb01'))
    def test_should_not_delete_host_directory_when_a_file_has_been_deleted_in_repository_host_directory(self):

        svn_service = SvnService(base_url=self.repo_url, path_to_config=get_svn_path_to_config())
        ConfigRpmMaker('1', svn_service).build()

        if call('svn delete -q -m "deleting hostspecific file devweb01" %s/config/host/devweb01/host_specific_file' % self.repo_url, shell=True):
            raise IntegrationTestException('Could not delete test data.')

        clean_up_deleted_hosts_data(svn_service, '3')

        self.assert_path_exists(build_config_viewer_host_directory('berweb01'))
        self.assert_path_exists(build_config_viewer_host_directory('tuvweb01'))
        self.assert_path_exists(build_config_viewer_host_directory('devweb01'))
    def test_should_not_delete_host_directory_when_a_file_has_been_deleted_in_repository_host_directory(
            self):

        svn_service = SvnService(base_url=self.repo_url,
                                 path_to_config=get_svn_path_to_config())
        ConfigRpmMaker('1', svn_service).build()

        if call('svn delete -q -m "deleting hostspecific file devweb01" %s/config/host/devweb01/host_specific_file'
                % self.repo_url,
                shell=True):
            raise IntegrationTestException('Could not delete test data.')

        clean_up_deleted_hosts_data(svn_service, '3')

        self.assert_path_exists(build_config_viewer_host_directory('berweb01'))
        self.assert_path_exists(build_config_viewer_host_directory('tuvweb01'))
        self.assert_path_exists(build_config_viewer_host_directory('devweb01'))
    def test_should_delete_config_viewer_host_directories_when_directories_have_been_deleted_in_repository(
            self):

        svn_service = SvnService(base_url=self.repo_url,
                                 path_to_config=get_svn_path_to_config())
        ConfigRpmMaker('1', svn_service).build()

        if call('svn delete -q -m "deleting host tuvweb01 and devweb01" {0}/config/host/devweb01 {0}/config/host/tuvweb01'
                .format(self.repo_url),
                shell=True):
            raise IntegrationTestException('Could not delete test data.')

        clean_up_deleted_hosts_data(svn_service, '3')

        self.assert_path_exists(build_config_viewer_host_directory('berweb01'))
        self.assert_path_does_not_exist(
            build_config_viewer_host_directory('devweb01'))
        self.assert_path_does_not_exist(
            build_config_viewer_host_directory('tuvweb01'))