Exemple #1
0
    def test_bind_multiple_url(self):
        """
        Tests that binding with a list of URLs will produce a mirror list and the
        correct mirrorlist entry in the repo entry.
        """

        # Test
        url_list = ['http://pulpserver', 'http://otherserver']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, {}, None, None, ENABLED, LOCK)

        # Verify
        self.assertTrue(os.path.exists(TEST_REPO_FILENAME))
        self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))

        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertTrue('baseurl' not in loaded)
        self.assertEqual(loaded['mirrorlist'], 'file:' + TEST_MIRROR_LIST_FILENAME)

        mirror_list_file = MirrorListFile(TEST_MIRROR_LIST_FILENAME)
        mirror_list_file.load()

        self.assertEqual(mirror_list_file.entries[0], 'http://pulpserver')
        self.assertEqual(mirror_list_file.entries[1], 'http://otherserver')
Exemple #2
0
    def test_multiple_entries_save_load(self):
        """
        Tests creating a new mirror list file with multiple entries, saving it, and then
        loading it back from disk.
        """

        # Test Save
        mirror_list = MirrorListFile(TEST_MIRROR_LIST_FILENAME)
        mirror_list.add_entry('http://cds-01')
        mirror_list.add_entry('http://cds-02')

        mirror_list.save()

        # Verify Save
        self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))

        # Test Load
        loaded = MirrorListFile(TEST_MIRROR_LIST_FILENAME)
        loaded.load()

        # Verify Load
        self.assertEqual(2, len(loaded.entries))

        #   Make sure the entries are returned in the correct order
        self.assertEqual('http://cds-01', loaded.entries[0])
        self.assertEqual('http://cds-02', loaded.entries[1])