Example #1
0
 def setup(self, mock_open, mock_temp, mock_command):
     tmpfile = mock.Mock()
     tmpfile.name = 'tmpfile'
     mock_temp.return_value = tmpfile
     root_bind = mock.Mock()
     root_bind.move_to_root = mock.Mock(
         return_value=['root-moved-arguments'])
     root_bind.root_dir = '../data'
     root_bind.shared_location = '/shared-dir'
     self.repo = RepositoryZypper(root_bind, ['exclude_docs'])
Example #2
0
 def test_custom_args_init_check_signatures(self, mock_open, mock_config,
                                            mock_temp, mock_command):
     runtime_zypp_config = mock.Mock()
     mock_config.return_value = runtime_zypp_config
     self.repo = RepositoryZypper(self.root_bind, ['check_signatures'])
     assert self.repo.custom_args == []
     assert runtime_zypp_config.set.call_args_list == [
         call('main', 'credentials.global.dir',
              '../data/shared-dir/zypper/credentials'),
         call('main', 'gpgcheck', '1'),
     ]
Example #3
0
 def __new__(self, root_bind, package_manager, custom_args=None):
     if package_manager == 'zypper':
         return RepositoryZypper(root_bind, custom_args)
     elif package_manager == 'dnf' or package_manager == 'yum':
         return RepositoryDnf(root_bind, custom_args)
     elif package_manager == 'apt-get':
         return RepositoryApt(root_bind, custom_args)
     else:
         raise KiwiRepositorySetupError(
             'Support for %s repository manager not implemented' %
             package_manager)
Example #4
0
 def test_custom_args_init_check_signatures(self, mock_config, mock_temp,
                                            mock_command):
     Defaults.set_platform_name('x86_64')
     runtime_zypp_config = mock.Mock()
     mock_config.return_value = runtime_zypp_config
     with patch('builtins.open', create=True):
         repo = RepositoryZypper(self.root_bind, ['check_signatures'])
         assert repo.custom_args == []
         assert runtime_zypp_config.set.call_args_list == [
             call('main', 'credentials.global.dir',
                  '../data/shared-dir/zypper/credentials'),
             call('main', 'arch', 'x86_64'),
             call('main', 'gpgcheck', '1'),
         ]
Example #5
0
    def setup(self, mock_open, mock_temp, mock_command):
        self.context_manager_mock = mock.Mock()
        self.file_mock = mock.Mock()
        self.enter_mock = mock.Mock()
        self.exit_mock = mock.Mock()
        self.enter_mock.return_value = self.file_mock
        setattr(self.context_manager_mock, '__enter__', self.enter_mock)
        setattr(self.context_manager_mock, '__exit__', self.exit_mock)

        tmpfile = mock.Mock()
        tmpfile.name = 'tmpfile'
        mock_temp.return_value = tmpfile
        self.root_bind = mock.Mock()
        self.root_bind.move_to_root = mock.Mock(
            return_value=['root-moved-arguments'])
        self.root_bind.root_dir = '../data'
        self.root_bind.shared_location = '/shared-dir'
        self.repo = RepositoryZypper(self.root_bind, ['exclude_docs'])
Example #6
0
    def setup(self, mock_temp, mock_command):
        self.context_manager_mock = mock.Mock()
        self.file_mock = mock.Mock()
        self.enter_mock = mock.Mock()
        self.exit_mock = mock.Mock()
        self.enter_mock.return_value = self.file_mock
        setattr(self.context_manager_mock, '__enter__', self.enter_mock)
        setattr(self.context_manager_mock, '__exit__', self.exit_mock)

        tmpfile = mock.Mock()
        tmpfile.name = 'tmpfile'
        mock_temp.return_value = tmpfile
        self.root_bind = mock.Mock()
        self.root_bind.root_dir = '../data'
        self.root_bind.shared_location = '/shared-dir'
        with patch('builtins.open', create=True):
            self.repo = RepositoryZypper(
                self.root_bind, ['exclude_docs', '_install_langs%en_US:de_DE'])
 def test_custom_args_init_excludedocs(
     self, mock_open, mock_temp, mock_command
 ):
     self.repo = RepositoryZypper(self.root_bind)
     assert self.repo.custom_args == []
Example #8
0
 def test_custom_args_init_excludedocs(self, mock_temp, mock_command):
     with patch('builtins.open', create=True):
         repo = RepositoryZypper(self.root_bind)
         assert repo.custom_args == []
Example #9
0
 def test_custom_args_init(self, mock_open, mock_temp, mock_command):
     self.repo = RepositoryZypper(mock.MagicMock())
     assert self.repo.custom_args == []