示例#1
0
    def __init__(self, repo_url, dst_dir, nectar_config, url_modify=None):
        """
        :param repo_url:        URL for the base of a yum repository
        :type  repo_url:        basestring
        :param dst_dir:         full path to a destination to which files
                                should be downloaded
        :type  dst_dir:         basestring
        :param nectar_config:   download config for nectar
        :type  nectar_config:   nectar.config.DownloaderConfig
        :param url_modify:      Optional URL modifier
        :type  url_modify:      pulp_rpm.plugins.importers.yum.utils.RepoURLModifier
        """
        super(MetadataFiles, self).__init__()

        self._url_modify = url_modify or utils.RepoURLModifier()
        self.repo_url = self._url_modify(repo_url)
        self.dst_dir = dst_dir
        self.event_listener = AggregatingEventListener()

        self.downloader = nectar_factory.create_downloader(
            self.repo_url, nectar_config, self.event_listener)

        self.revision = None
        self.metadata = {}
        self.dbs = {}
示例#2
0
 def test_kwargs_update(self):
     # test that passed-in kwargs are applied and take precedence over the stateful config
     url_modify = utils.RepoURLModifier(query_auth_token='foo')
     modified_url = url_modify(self.test_url, query_auth_token='bar')
     modified_url_query = urlparse(modified_url).query
     self.assertEqual(modified_url_query, 'bar')
     self.assertEqual(url_modify._query_auth_token, 'foo')
示例#3
0
    def test_bad_kwargs(self):
        # can't instantiate with bad kwargs
        self.assertRaises(TypeError, utils.RepoURLModifier, bad_kwarg="I'm not supported.")

        # can't call with bad kwargs
        url_modify = utils.RepoURLModifier()
        self.assertRaises(LookupError, url_modify, 'url_goes_here',
                          bad_kwarg="I'm not supported either.")
示例#4
0
    def test_kwargs_update(self):
        # test that passed-in kwargs are applied and take precedence over the initial config
        url_modify = utils.RepoURLModifier(path_append='appended')
        modified_url = url_modify(self.test_url, path_append='updated', ensure_trailing_slash=True)
        modified_url_path = urlparse(modified_url).path
        self.assertEqual(modified_url_path, '/path/updated/')

        # make sure the kwargs didn't overwrite the modifier config
        self.assertEqual(url_modify.conf['path_append'], 'appended')
        self.assertTrue(url_modify.conf['ensure_trailing_slash'] is None)
示例#5
0
    def test_add_trailing_slash(self):
        # test that a trailing slash is added to the path
        url_modify = utils.RepoURLModifier(ensure_trailing_slash=True)
        modified_url = url_modify(self.test_url)
        modified_url_path = urlparse(modified_url).path
        self.assertEqual(modified_url_path, '/path/')

        # for fun, try to add another trailing slash to the modified, which should make no change
        modified_url = url_modify(modified_url)
        modified_url_path = urlparse(modified_url).path
        self.assertEqual(modified_url_path, '/path/')
示例#6
0
 def test_query_auth_token(self):
     # test the the query string is properly overwritten with the sles auth token
     url_modify = utils.RepoURLModifier(query_auth_token='gabbagabbahey')
     modified_url = url_modify(self.test_url)
     self.assertTrue(modified_url.endswith('?gabbagabbahey#fragment'))
示例#7
0
 def test_path_append(self):
     # test that a path fragment is appended correctly
     url_modify = utils.RepoURLModifier(path_append='appended')
     modified_url = url_modify(self.test_url)
     modified_url_path = urlparse(modified_url).path
     self.assertEqual(modified_url_path, '/path/appended')
示例#8
0
 def test_no_config(self):
     # test that with no configuration, the URL modifier does nothing
     url_modify = utils.RepoURLModifier()
     modified_url = url_modify(self.test_url)
     self.assertEqual(modified_url, self.test_url)