コード例 #1
0
    def test_get_repo_by_name(self):
        """ Test the get_repo_by_name function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_repo_by_name(
            self.session, 'pub/fedora/linux/updates/testing/19/x86_64')
        self.assertEqual(results, None)

        tests.create_base_items(self.session)
        tests.create_version(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_repository(self.session)

        results = mirrormanager2.lib.get_repo_by_name(
            self.session, 'pub/fedora/linux/updates/testing/19/x86_64')
        self.assertEqual(
            results.name, 'pub/fedora/linux/updates/testing/19/x86_64')

        results = mirrormanager2.lib.get_repo_by_name(
            self.session, 'pub/fedora/linux/updates/testing/20/x86_64')
        self.assertEqual(
            results.name, 'pub/fedora/linux/updates/testing/20/x86_64')

        results = mirrormanager2.lib.get_repo_by_name(
            self.session, 'pub/fedora/linux/updates/testing/19/i386')
        self.assertEqual(results, None)
コード例 #2
0
ファイル: test_mmlib.py プロジェクト: sitedata/mirrormanager2
    def test_get_repo_prefix_arch(self):
        """ Test the get_repo_prefix_arch function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_repo_prefix_arch(
            self.session, 'updates-testing-f20', 'x86_64')
        self.assertEqual(results, None)

        tests.create_base_items(self.session)
        tests.create_version(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_repository(self.session)

        results = mirrormanager2.lib.get_repo_prefix_arch(
            self.session, 'updates-testing-f26', 'x86_64')
        self.assertEqual(results.name,
                         'pub/fedora/linux/updates/testing/26/x86_64')

        results = mirrormanager2.lib.get_repo_prefix_arch(
            self.session, 'updates-testing-f27', 'x86_64')
        self.assertEqual(results.name,
                         'pub/fedora/linux/updates/testing/27/x86_64')

        results = mirrormanager2.lib.get_repo_prefix_arch(
            self.session, 'updates-testing-f20', 'i386')
        self.assertEqual(results, None)
コード例 #3
0
    def test_get_host_category(self):
        """ Test the get_host_category function of mirrormanager2.lib. """
        results = mirrormanager2.lib.get_host_category(self.session, 1)
        self.assertEqual(results, None)

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)

        results = mirrormanager2.lib.get_host_category(self.session, 1)
        self.assertEqual(results.host.name, 'mirror.localhost')
        self.assertEqual(results.host.country, 'US')
        results = mirrormanager2.lib.get_host_category(self.session, 2)
        self.assertEqual(results.host.name, 'mirror.localhost')
        self.assertEqual(results.host.country, 'US')
        results = mirrormanager2.lib.get_host_category(self.session, 3)
        self.assertEqual(results.host.name, 'mirror2.localhost')
        self.assertEqual(results.host.country, 'FR')
        results = mirrormanager2.lib.get_host_category(self.session, 4)
        self.assertEqual(results.host.name, 'mirror2.localhost')
        self.assertEqual(results.host.country, 'FR')
        results = mirrormanager2.lib.get_host_category(self.session, 5)
        self.assertEqual(results, None)
コード例 #4
0
ファイル: test_mmlib.py プロジェクト: sitedata/mirrormanager2
    def test_get_hostcategorydir_by_hostcategoryid_and_path(self):
        """ Test the get_hostcategorydir_by_hostcategoryid_and_path
        function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib \
            .get_hostcategorydir_by_hostcategoryid_and_path(
                self.session, 2, 'pub/fedora/linux/releases/21')
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategorydir(self.session)

        results = mirrormanager2.lib \
            .get_hostcategorydir_by_hostcategoryid_and_path(
                self.session, 3, 'pub/fedora/linux/releases/27')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].directory.name,
                         'pub/fedora/linux/releases/27')
        self.assertEqual(results[0].host_category.category.name,
                         'Fedora Linux')
コード例 #5
0
    def test_get_host_category(self):
        """ Test the get_host_category function of mirrormanager2.lib. """
        results = mirrormanager2.lib.get_host_category(self.session, 1)
        self.assertEqual(results, None)

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)

        results = mirrormanager2.lib.get_host_category(self.session, 1)
        self.assertEqual(results.host.name, 'mirror.localhost')
        self.assertEqual(results.host.country, 'US')
        results = mirrormanager2.lib.get_host_category(self.session, 2)
        self.assertEqual(results.host.name, 'mirror.localhost')
        self.assertEqual(results.host.country, 'US')
        results = mirrormanager2.lib.get_host_category(self.session, 3)
        self.assertEqual(results.host.name, 'mirror2.localhost')
        self.assertEqual(results.host.country, 'FR')
        results = mirrormanager2.lib.get_host_category(self.session, 4)
        self.assertEqual(results.host.name, 'mirror2.localhost')
        self.assertEqual(results.host.country, 'FR')
        results = mirrormanager2.lib.get_host_category(self.session, 5)
        self.assertEqual(results, None)
コード例 #6
0
    def test_get_host_category_by_hostid_category(self):
        """ Test the get_host_category_by_hostid_category function of
        mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_host_category_by_hostid_category(
            self.session, 1, 'Fedora Linux')
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)

        results = mirrormanager2.lib.get_host_category_by_hostid_category(
            self.session, 1, 'Fedora Linux')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].host.name, 'mirror.localhost')
        self.assertEqual(results[0].host.country, 'US')

        results = mirrormanager2.lib.get_host_category_by_hostid_category(
            self.session, 2, 'Fedora Linux')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].host.name, 'mirror2.localhost')
        self.assertEqual(results[0].host.country, 'FR')

        results = mirrormanager2.lib.get_host_category_by_hostid_category(
            self.session, 3, 'Fedora Linux')
        self.assertEqual(results, [])
コード例 #7
0
    def setUp(self):
        """ Set up the environnment, ran before every test. """
        super(FlaskUiAdminTest, self).setUp()

        mirrormanager2.app.APP.config['TESTING'] = True
        mirrormanager2.app.SESSION = self.session
        mirrormanager2.app.ADMIN.SESSION = self.session
        mirrormanager2.app.APP.SESSION = self.session
        mirrormanager2.admin.SESSION = self.session
        mirrormanager2.admin.ADMIN.SESSION = self.session
        mirrormanager2.admin.APP.SESSION = self.session
        for view in mirrormanager2.admin.VIEWS:
            view.session = self.session
        self.app = mirrormanager2.app.APP.test_client()

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_site_admin(self.session)
        tests.create_hosts(self.session)
        tests.create_location(self.session)
        tests.create_netblockcountry(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)
        tests.create_hostcategorydir(self.session)
        tests.create_categorydirectory(self.session)
        tests.create_version(self.session)
        tests.create_repository(self.session)
        tests.create_repositoryredirect(self.session)
コード例 #8
0
    def test_get_repo_by_name(self):
        """ Test the get_repo_by_name function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_repo_by_name(
            self.session, 'pub/fedora/linux/updates/testing/19/x86_64')
        self.assertEqual(results, None)

        tests.create_base_items(self.session)
        tests.create_version(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_repository(self.session)

        results = mirrormanager2.lib.get_repo_by_name(
            self.session, 'pub/fedora/linux/updates/testing/19/x86_64')
        self.assertEqual(results.name,
                         'pub/fedora/linux/updates/testing/19/x86_64')

        results = mirrormanager2.lib.get_repo_by_name(
            self.session, 'pub/fedora/linux/updates/testing/20/x86_64')
        self.assertEqual(results.name,
                         'pub/fedora/linux/updates/testing/20/x86_64')

        results = mirrormanager2.lib.get_repo_by_name(
            self.session, 'pub/fedora/linux/updates/testing/19/i386')
        self.assertEqual(results, None)
コード例 #9
0
    def test_get_host_category_url_by_id(self):
        """ Test the get_host_category_url_by_id function of
        mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_host_category_url_by_id(
            self.session, 1)
        self.assertEqual(results, None)

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)

        for i in range(4):
            results = mirrormanager2.lib.get_host_category_url_by_id(
                self.session, i + 1)
            self.assertEqual(results.host_category.host.name,
                             'mirror.localhost')
            self.assertEqual(results.host_category.host.country, 'US')

        results = mirrormanager2.lib.get_host_category_url_by_id(
            self.session, 5)
        self.assertEqual(results, None)
コード例 #10
0
    def setUp(self):
        """ Set up the environnment, ran before every test. """
        super(FlaskUiAdminTest, self).setUp()

        mirrormanager2.app.APP.config['TESTING'] = True
        mirrormanager2.app.SESSION = self.session
        mirrormanager2.app.ADMIN.SESSION = self.session
        mirrormanager2.app.APP.SESSION = self.session
        mirrormanager2.admin.SESSION = self.session
        mirrormanager2.admin.ADMIN.SESSION = self.session
        mirrormanager2.admin.APP.SESSION = self.session
        for view in mirrormanager2.admin.VIEWS:
            view.session = self.session
        self.app = mirrormanager2.app.APP.test_client()

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_site_admin(self.session)
        tests.create_hosts(self.session)
        tests.create_location(self.session)
        tests.create_netblockcountry(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)
        tests.create_hostcategorydir(self.session)
        tests.create_categorydirectory(self.session)
        tests.create_version(self.session)
        tests.create_repository(self.session)
        tests.create_repositoryredirect(self.session)
コード例 #11
0
    def test_get_repositories(self):
        """ Test the get_repositories function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_version(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_repository(self.session)

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 3)
        self.assertEqual(
            results[0].name, 'pub/fedora/linux/updates/testing/19/x86_64')
        self.assertEqual(results[0].arch.name, 'x86_64')

        self.assertEqual(
            results[1].name, 'pub/fedora/linux/updates/testing/20/x86_64')
        self.assertEqual(results[1].arch.name, 'x86_64')

        self.assertEqual(
            results[2].name, 'pub/fedora/linux/updates/testing/21/x86_64')
        self.assertEqual(results[2].arch.name, 'x86_64')
コード例 #12
0
    def test_get_host_category_url_by_id(self):
        """ Test the get_host_category_url_by_id function of
        mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_host_category_url_by_id(
            self.session, 1)
        self.assertEqual(results, None)

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)

        for i in range(4):
            results = mirrormanager2.lib.get_host_category_url_by_id(
                self.session, i+1)
            self.assertEqual(
                results.host_category.host.name, 'mirror.localhost')
            self.assertEqual(
                results.host_category.host.country, 'US')

        results = mirrormanager2.lib.get_host_category_url_by_id(
            self.session, 5)
        self.assertEqual(results, None)
コード例 #13
0
    def test_get_repositories(self):
        """ Test the get_repositories function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_version(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_repository(self.session)

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name,
                         'pub/fedora/linux/updates/testing/19/x86_64')
        self.assertEqual(results[0].arch.name, 'x86_64')

        self.assertEqual(results[1].name,
                         'pub/fedora/linux/updates/testing/20/x86_64')
        self.assertEqual(results[1].arch.name, 'x86_64')

        self.assertEqual(results[2].name,
                         'pub/fedora/linux/updates/testing/21/x86_64')
        self.assertEqual(results[2].arch.name, 'x86_64')
コード例 #14
0
    def test_get_host_category_by_hostid_category(self):
        """ Test the get_host_category_by_hostid_category function of
        mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_host_category_by_hostid_category(
            self.session, 1, 'Fedora Linux')
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)

        results = mirrormanager2.lib.get_host_category_by_hostid_category(
            self.session, 1, 'Fedora Linux')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].host.name, 'mirror.localhost')
        self.assertEqual(results[0].host.country, 'US')

        results = mirrormanager2.lib.get_host_category_by_hostid_category(
            self.session, 2, 'Fedora Linux')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].host.name, 'mirror2.localhost')
        self.assertEqual(results[0].host.country, 'FR')

        results = mirrormanager2.lib.get_host_category_by_hostid_category(
            self.session, 3, 'Fedora Linux')
        self.assertEqual(results, [])
コード例 #15
0
    def test_category_repr(self):
        """ Test the Category.__repr__ object of mirrormanager2.lib.model.
        """
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)

        item = model.Category.get(self.session, 1)
        self.assertEqual(str(item), '<Category(1 - Fedora Linux)>')
        item = model.Category.get(self.session, 2)
        self.assertEqual(str(item), '<Category(2 - Fedora EPEL)>')
コード例 #16
0
    def test_categorydirectory_repr(self):
        """ Test the CategoryDirectory.__repr__ object of mirrormanager2.lib.model.
        """
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        item = mirrormanager2.lib.get_category_directory(self.session)
        self.assertEqual(str(item[0]), '<CategoryDirectory(1 - 1)>')
        self.assertEqual(str(item[1]), '<CategoryDirectory(2 - 3)>')
コード例 #17
0
    def test_category_repr(self):
        """ Test the Category.__repr__ object of mirrormanager2.lib.model.
        """
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)

        item = model.Category.get(self.session, 1)
        self.assertEqual(str(item), '<Category(1 - Fedora Linux)>')
        item = model.Category.get(self.session, 2)
        self.assertEqual(str(item), '<Category(2 - Fedora EPEL)>')
コード例 #18
0
    def test_categorydirectory_repr(self):
        """ Test the CategoryDirectory.__repr__ object of mirrormanager2.lib.model.
        """
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        item = mirrormanager2.lib.get_category_directory(self.session)
        self.assertEqual(str(item[0]), '<CategoryDirectory(1 - 1)>')
        self.assertEqual(str(item[1]), '<CategoryDirectory(2 - 3)>')
コード例 #19
0
    def test_version_arches(self):
        """ Test the Version.arches object of mirrormanager2.lib.model.
        """
        tests.create_base_items(self.session)
        tests.create_version(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_repository(self.session)

        item = model.Version.get(self.session, 1)
        self.assertEqual(item.arches, set([u'x86_64']))
        item = model.Version.get(self.session, 2)
        self.assertEqual(item.arches, set([]))
        item = model.Version.get(self.session, 3)
        self.assertEqual(item.arches, set([u'x86_64']))
コード例 #20
0
    def test_version_arches(self):
        """ Test the Version.arches object of mirrormanager2.lib.model.
        """
        tests.create_base_items(self.session)
        tests.create_version(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_repository(self.session)

        item = model.Version.get(self.session, 1)
        self.assertEqual(item.arches, set([u'x86_64']))
        item = model.Version.get(self.session, 2)
        self.assertEqual(item.arches, set([]))
        item = model.Version.get(self.session, 3)
        self.assertEqual(item.arches, set([u'x86_64']))
コード例 #21
0
    def test_get_categories(self):
        """ Test the get_categories function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_categories(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)

        results = mirrormanager2.lib.get_categories(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'Fedora Linux')
        self.assertEqual(results[0].product.name, 'Fedora')
        self.assertEqual(results[1].name, 'Fedora EPEL')
        self.assertEqual(results[1].product.name, 'EPEL')
コード例 #22
0
    def test_get_categories(self):
        """ Test the get_categories function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_categories(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)

        results = mirrormanager2.lib.get_categories(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'Fedora Linux')
        self.assertEqual(results[0].product.name, 'Fedora')
        self.assertEqual(results[1].name, 'Fedora EPEL')
        self.assertEqual(results[1].product.name, 'EPEL')
コード例 #23
0
ファイル: test_mmlib.py プロジェクト: sitedata/mirrormanager2
    def test_get_category_directory(self):
        """ Test the get_category_directory function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_category_directory(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        results = mirrormanager2.lib.get_category_directory(self.session)
        self.assertEqual(len(results), 4)
        self.assertEqual(results[0].category.name, 'Fedora Linux')
        self.assertEqual(results[0].directory.name, 'pub/fedora/linux')
        self.assertEqual(results[1].category.name, 'Fedora EPEL')
        self.assertEqual(results[1].directory.name, 'pub/epel')
コード例 #24
0
    def test_query_directories(self):
        """ Test the query_directories function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.query_directories(self.session)
        self.assertEqual(len(results), 0)

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)
        tests.create_categorydirectory(self.session)

        results = mirrormanager2.lib.query_directories(self.session)
        self.assertEqual(len(results), 12)
コード例 #25
0
    def test_query_directories(self):
        """ Test the query_directories function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.query_directories(self.session)
        self.assertEqual(len(results), 0)

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)
        tests.create_categorydirectory(self.session)

        results = mirrormanager2.lib.query_directories(self.session)
        self.assertEqual(len(results), 12)
コード例 #26
0
    def test_mdtr_no_data(self):
        """ Test the mdtr script without the appropriate data in the
        database.
        """
        command = self.command[:]

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stderr, '')
        self.assertEqual(
            stdout,
            "Category 'Fedora Linux' not found, exiting\n"
            "Available categories:\n")

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, 'Version 27 not found for product Fedora\n')
        self.assertEqual(stderr, '')

        # One step further
        tests.create_version(self.session)

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, '')
        self.assertEqual(stderr, '')
コード例 #27
0
ファイル: test_mdtr.py プロジェクト: nphilipp/mirrormanager2
    def test_mdtr_no_data(self):
        """ Test the mdtr script without the appropriate data in the
        database.
        """
        command = self.command[:]

        process = subprocess.Popen(args=command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stderr, '')
        self.assertEqual(
            stdout, "Category 'Fedora Linux' not found, exiting\n"
            "Available categories:\n")

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        process = subprocess.Popen(args=command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, 'Version 27 not found for product Fedora\n')
        self.assertEqual(stderr, '')

        # One step further
        tests.create_version(self.session)

        process = subprocess.Popen(args=command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, '')
        self.assertEqual(stderr, '')
コード例 #28
0
    def test_get_category_directory(self):
        """ Test the get_category_directory function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_category_directory(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        results = mirrormanager2.lib.get_category_directory(self.session)
        self.assertEqual(len(results), 4)
        self.assertEqual(
            results[0].category.name, 'Fedora Linux')
        self.assertEqual(
            results[0].directory.name, 'pub/fedora/linux/releases')
        self.assertEqual(
            results[1].category.name, 'Fedora EPEL')
        self.assertEqual(
            results[1].directory.name, 'pub/epel')
コード例 #29
0
    def test_get_host_category_url(self):
        """ Test the get_host_category_url function of
        mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_host_category_url(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)

        results = mirrormanager2.lib.get_host_category_url(self.session)
        self.assertEqual(len(results), 4)
        for i in range(4):
            self.assertEqual(results[i].host_category.host.name,
                             'mirror.localhost')
            self.assertEqual(results[i].host_category.host.country, 'US')
コード例 #30
0
    def test_get_host_category_url(self):
        """ Test the get_host_category_url function of
        mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_host_category_url(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)

        results = mirrormanager2.lib.get_host_category_url(self.session)
        self.assertEqual(len(results), 4)
        for i in range(4):
            self.assertEqual(
                results[i].host_category.host.name, 'mirror.localhost')
            self.assertEqual(
                results[i].host_category.host.country, 'US')
コード例 #31
0
    def test_get_category_by_name(self):
        """ Test the get_category_by_name function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_category_by_name(
            self.session, 'Fedora EPEL')
        self.assertEqual(results, None)

        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)

        results = mirrormanager2.lib.get_category_by_name(
            self.session, 'Fedora EPEL')
        self.assertEqual(results.name, 'Fedora EPEL')
        self.assertEqual(results.product.name, 'EPEL')

        results = mirrormanager2.lib.get_category_by_name(
            self.session, 'Fedora Linux')
        self.assertEqual(results.name, 'Fedora Linux')
        self.assertEqual(results.product.name, 'Fedora')

        results = mirrormanager2.lib.get_category_by_name(self.session, 'foo')
        self.assertEqual(results, None)
コード例 #32
0
    def test_host_set_not_up2date(self):
        """ Test the Host.set_not_up2date object of mirrormanager2.lib.model.
        """
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategorydir(self.session)

        item = model.Host.get(self.session, 1)
        # Before change, all is up2date
        for hc in item.categories:
            for hcd in hc.directories:
               self.assertTrue(hcd.up2date)

        item.set_not_up2date(self.session)

        # After change, all is *not* up2date
        for hc in item.categories:
            for hcd in hc.directories:
               self.assertFalse(hcd.up2date)
コード例 #33
0
    def test_get_hostcategorydir_by_hostcategoryid_and_path(self):
        """ Test the get_hostcategorydir_by_hostcategoryid_and_path
        function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_hostcategorydir_by_hostcategoryid_and_path(
            self.session, 2, 'pub/fedora/linux/releases/21')
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategorydir(self.session)

        results = mirrormanager2.lib.get_hostcategorydir_by_hostcategoryid_and_path(
            self.session, 3, 'pub/fedora/linux/releases/21')
        self.assertEqual(len(results), 1)
        self.assertEqual(
            results[0].directory.name, 'pub/fedora/linux/releases/21')
        self.assertEqual(
            results[0].host_category.category.name, 'Fedora Linux')
コード例 #34
0
    def test_host_set_not_up2date(self):
        """ Test the Host.set_not_up2date object of mirrormanager2.lib.model.
        """
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategorydir(self.session)

        item = model.Host.get(self.session, 1)
        # Before change, all is up2date
        for hc in item.categories:
            for hcd in hc.directories:
                self.assertTrue(hcd.up2date)

        item.set_not_up2date(self.session)

        # After change, all is *not* up2date
        for hc in item.categories:
            for hcd in hc.directories:
                self.assertFalse(hcd.up2date)
コード例 #35
0
    def test_get_category_by_name(self):
        """ Test the get_category_by_name function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_category_by_name(
            self.session, 'Fedora EPEL')
        self.assertEqual(results, None)

        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)

        results = mirrormanager2.lib.get_category_by_name(
            self.session, 'Fedora EPEL')
        self.assertEqual(results.name, 'Fedora EPEL')
        self.assertEqual(results.product.name, 'EPEL')

        results = mirrormanager2.lib.get_category_by_name(
            self.session, 'Fedora Linux')
        self.assertEqual(results.name, 'Fedora Linux')
        self.assertEqual(results.product.name, 'Fedora')

        results = mirrormanager2.lib.get_category_by_name(
            self.session, 'foo')
        self.assertEqual(results, None)
コード例 #36
0
    def test_mta(self):
        """ Test the mta script. """
        command = self.command[:]

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stderr, '')
        self.assertEqual(
            stdout,
            "No category could be found by the name: Fedora Linux\n")

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)
        tests.create_version(self.session)
        tests.create_repository(self.session)

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout,
            'No category could be found by the name: Fedora Archive\n')
        self.assertEqual(stderr, '')

        # One step further
        item = model.Directory(
            name='pub/archive',
            readable=True,
        )
        self.session.add(item)
        self.session.flush()
        item = model.Category(
            name='Fedora Archive',
            product_id=1,
            canonicalhost='http://archive.fedoraproject.org',
            topdir_id=10,
            publiclist=True
        )
        self.session.add(item)

        item = model.CategoryDirectory(
            directory_id=6,
            category_id=1,
        )
        self.session.add(item)
        item = model.CategoryDirectory(
            directory_id=8,
            category_id=1,
        )
        self.session.add(item)

        self.session.commit()

        # Before the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].prefix, 'updates-testing-f25')
        self.assertEqual(
            results[0].directory.name,
            'pub/fedora/linux/updates/testing/25/x86_64')
        self.assertEqual(results[1].prefix, 'updates-testing-f26')
        self.assertEqual(
            results[1].directory.name,
            'pub/fedora/linux/updates/testing/26/x86_64')
        self.assertEqual(results[2].prefix, 'updates-testing-f27')
        self.assertEqual(
            results[2].directory.name,
            'pub/fedora/linux/updates/testing/27/x86_64')

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 1 more here, 9+1=10
        self.assertEqual(len(results), 10)
        self.assertEqual(results[0].name, 'pub/fedora/linux')
        self.assertEqual(results[1].name, 'pub/fedora/linux/extras')
        self.assertEqual(results[2].name, 'pub/epel')
        self.assertEqual(results[3].name, 'pub/fedora/linux/releases/26')
        self.assertEqual(results[4].name, 'pub/fedora/linux/releases/27')
        self.assertEqual(
            results[5].name,
            'pub/archive/fedora/linux/releases/26/Everything/source')
        self.assertEqual(
            results[6].name,
            'pub/fedora/linux/updates/testing/25/x86_64')
        self.assertEqual(
            results[7].name,
            'pub/fedora/linux/updates/testing/26/x86_64')
        self.assertEqual(
            results[8].name,
            'pub/fedora/linux/updates/testing/27/x86_64')
        self.assertEqual(results[9].name, 'pub/archive')

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout,
            'trying to find pub/archive/fedora/linux/updates/testing/'
            '26/x86_64\n'
            'Unable to find a directory in [Fedora Archive] for pub/fedora/'
            'linux/updates/testing/26/x86_64\n')
        self.assertEqual(stderr, '')

        # Run the script so that it works

        item = model.Directory(
            name='pub/archive/fedora/linux/updates/testing/26/x86_64',
            readable=True,
        )
        self.session.add(item)
        self.session.commit()

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout,
            'trying to find pub/archive/fedora/'
            'linux/updates/testing/26/x86_64\n'
            'pub/fedora/linux/updates/testing/26/x86_64 => '
            'pub/archive/fedora/linux/updates/testing/26/x86_64\n')
        self.assertEqual(stderr, '')

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].prefix, 'updates-testing-f25')
        self.assertEqual(
            results[0].directory.name,
            'pub/fedora/linux/updates/testing/25/x86_64')
        self.assertEqual(results[1].prefix, 'updates-testing-f26')
        self.assertEqual(
            results[1].directory.name,
            'pub/archive/fedora/linux/updates/testing/26/x86_64')
        self.assertEqual(results[2].prefix, 'updates-testing-f27')
        self.assertEqual(
            results[2].directory.name,
            'pub/fedora/linux/updates/testing/27/x86_64')

        # After the script

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 1 more here, 9+1=10
        self.assertEqual(len(results), 11)
        self.assertEqual(results[0].name, 'pub/fedora/linux')
        self.assertEqual(results[1].name, 'pub/fedora/linux/extras')
        self.assertEqual(results[2].name, 'pub/epel')
        self.assertEqual(results[3].name, 'pub/fedora/linux/releases/26')
        self.assertEqual(results[4].name, 'pub/fedora/linux/releases/27')
        self.assertEqual(
            results[5].name,
            'pub/archive/fedora/linux/releases/26/Everything/source')
        self.assertEqual(
            results[6].name,
            'pub/fedora/linux/updates/testing/25/x86_64')
        self.assertEqual(
            results[7].name,
            'pub/fedora/linux/updates/testing/26/x86_64')
        self.assertEqual(
            results[8].name,
            'pub/fedora/linux/updates/testing/27/x86_64')
        self.assertEqual(results[9].name, 'pub/archive')
        self.assertEqual(
            results[10].name,
            'pub/archive/fedora/linux/updates/testing/26/x86_64')
コード例 #37
0
    def test_1_umdl(self):
        """ Test the umdl cron. """

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        # Run the UDML

        process = subprocess.Popen(args=self.umdl_command.split(),
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, '')
        self.assertEqual(stderr, '')

        with open(self.logfile) as stream:
            logs = stream.readlines()
        logs = ''.join([log.split(':', 3)[-1] for log in logs])

        for i in [
                'N/A:Starting umdl', 'Fedora Linux: has changed: 0 !=',
                'Fedora Linux:development has changed: 0 !=',
                'Fedora Linux:releases/20/Fedora has changed: 0 !=',
                'Fedora/source/SRPMS/r has changed: 0 !=',
                'releases/20/Fedora/x86_64/iso has changed: 0 !=',
                'releases/20/Live/x86_64 has changed: 0 !=',
                'Fedora Linux:Updating FileDetail <mirrormanager2.lib.model',
                'Created Version(product=<Product(2 - Fedora)>',
                'Version(product=<Product(2 - Fedora)>, name=20',
                'Repository(prefix=None, version=20, arch=source',
                'ategory Fedora Secondary Arches does not exist',
                'Fedora Other:Refresh the list of repomd.xml'
        ]:
            self.assertTrue(i in logs)

        # The DB should now be filled with what UMDL added, so let's check it
        results = mirrormanager2.lib.query_directories(self.session)
        self.assertEqual(len(results), 0)

        results = mirrormanager2.lib.get_versions(self.session)
        self.assertEqual(len(results), 2)
        for result in results:
            version_names = ['22', '20']
            self.assertTrue(result.name in version_names)
            if result.name == '22':
                self.assertEqual(result.product.name, 'Fedora')
            if result.name == '20':
                self.assertEqual(result.product.name, 'Fedora')

        results = mirrormanager2.lib.get_categories(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'Fedora Linux')
        self.assertEqual(results[1].name, 'Fedora EPEL')

        results = mirrormanager2.lib.get_products(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'EPEL')
        self.assertEqual(results[1].name, 'Fedora')

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 3)
        check_counter = 0
        for result in results:
            if result.name == 'pub/fedora/linux/development/22/x86_64/os':
                self.assertEqual(result.category.name, 'Fedora Linux')
                self.assertEqual(result.version.name, '22')
                self.assertEqual(result.arch.name, 'x86_64')
                self.assertEqual(result.directory.name,
                                 'pub/fedora/linux/development/22/x86_64/os')
                self.assertEqual(result.prefix, None)
                check_counter += 1
            if result.name == 'pub/fedora/linux/releases/20/Fedora/x86_64/os':
                self.assertEqual(result.category.name, 'Fedora Linux')
                self.assertEqual(result.version.name, '20')
                self.assertEqual(result.arch.name, 'x86_64')
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/x86_64/os')
                self.assertEqual(result.prefix, 'fedora-install-20')
                check_counter += 1

        self.assertEqual(check_counter, 2)

        results = mirrormanager2.lib.get_arches(self.session)
        self.assertEqual(len(results), 4)
        self.assertEqual(results[0].name, 'i386')
        self.assertEqual(results[1].name, 'ppc')
        self.assertEqual(results[2].name, 'source')
        self.assertEqual(results[3].name, 'x86_64')

        results = mirrormanager2.lib.get_directories(self.session)
        # tree testdata/pub says there are 49 directories and 49 files
        # There are 7 directories added by create_directory which are not
        # present on the FS, 49 + 7 = 56, so we are good \ó/
        self.assertEqual(len(results), 56)
        self.assertEqual(results[0].name, 'pub/fedora/linux')
        self.assertEqual(results[1].name, 'pub/fedora/linux/extras')
        self.assertEqual(results[2].name, 'pub/epel')
        self.assertEqual(results[3].name, 'pub/fedora/linux/releases/26')
        self.assertEqual(results[4].name, 'pub/fedora/linux/releases/27')
        self.assertEqual(
            results[5].name,
            'pub/archive/fedora/linux/releases/26/Everything/source')
        self.assertEqual(results[20].name,
                         'pub/fedora/linux/releases/20/Fedora/source/SRPMS/b')

        results = mirrormanager2.lib.get_file_detail(self.session,
                                                     'repomd.xml', 7)
        self.assertEqual(results, None)

        results = mirrormanager2.lib.get_file_details(self.session)
        self.assertEqual(len(results), 7)

        check_counter = 0
        for result in results:
            if result.filename == 'Fedora-20-x86_64-DVD.iso':
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/x86_64/iso')
                self.assertEqual(result.sha512, None)
                self.assertEqual(
                    result.sha256,
                    'f2eeed5102b8890e9e6f4b9053717fe73031e699c4b76dc7028749ab66e7f917'
                )
                check_counter += 1

            elif result.filename == 'Fedora-20-x86_64-netinst.iso':
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/x86_64/iso')
                self.assertEqual(result.sha512, None)
                self.assertEqual(
                    result.sha256,
                    '376be7d4855ad6281cb139430606a782fd6189dcb01d7b61448e915802cc350f'
                )
                check_counter += 1

            elif result.filename == 'Fedora-Live-Desktop-x86_64-20-1.iso':
                self.assertEqual(result.directory.name,
                                 'pub/fedora/linux/releases/20/Live/x86_64')
                self.assertEqual(result.sha512, None)
                self.assertEqual(
                    result.sha256,
                    'cc0333be93c7ff2fb3148cb29360d2453f78913cc8aa6c6289ae6823372a77d2'
                )
                check_counter += 1

            elif result.filename == 'Fedora-Live-KDE-x86_64-20-1.iso':
                self.assertEqual(result.directory.name,
                                 'pub/fedora/linux/releases/20/Live/x86_64')
                self.assertEqual(result.sha512, None)
                self.assertEqual(
                    result.sha256,
                    '08360a253b4a40dff948e568dba1d2ae9d931797f57aa08576b8b9f1ef7e4745'
                )
                check_counter += 1

            elif result.md5 == 'd0fb87891c3bfbdaf7a225f57e9ba6ee':
                self.assertEqual(result.filename, 'repomd.xml')
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/development/22/x86_64/os/repodata')
                self.assertEqual(
                    result.sha256,
                    '860f0f832f7a641cf8f7e27172ef9b2492ce849388e43f372af7e512aa646677'
                )
                self.assertEqual(
                    result.sha512,
                    '7bb9a0bae076ccbbcd086163a1d4f33b62321aa6991d135c42bf3f6c42c4eb'
                    '465a0b42c62efa809708543fcd69511cb19cd7111d5ff295a50253b9c7659b'
                    'b9d6')
                check_counter += 1

            elif result.md5 == '082970dfa804fdcfaed2e15e2e5fba7d':
                self.assertEqual(result.filename, 'repomd.xml')
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/source/SRPMS/repodata'
                )
                self.assertEqual(
                    result.sha256,
                    '9a4738934092cf17e4540ee9cab741e922eb8306875ae5621feb01ebeb1f67f2'
                )
                self.assertEqual(
                    result.sha512,
                    '3351c7a6b1d2bd94e375d09324a9280b8becfe4dea40a227c3b270ddcedb19'
                    'f420eec3f2c6a39a1edcdf52f80d31eb47a0ba25057ced2e3182dd212bc746'
                    '6ba2')
                check_counter += 1

            elif result.md5 == '49db42c616518f465014c3605de4414d':
                self.assertEqual(result.filename, 'repomd.xml')
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/x86_64/os/repodata')
                self.assertEqual(
                    result.sha256,
                    '108b4102829c0839c7712832577fe7da24f0a9491f4dc25d4145efe6aced2ebf'
                )
                self.assertEqual(
                    result.sha512,
                    '50ed8cb8f4daf8bcd1d0ccee1710b8a87ee8de5861fb15a1023d6558328795'
                    'f42dade3e025c09c20ade36c77a3a82d9cdce1a2e2ad171f9974bc1889b591'
                    '8020')
                check_counter += 1

        self.assertEqual(check_counter, 7)

        results = mirrormanager2.lib.get_host_category_dirs(self.session)
        self.assertEqual(len(results), 0)
コード例 #38
0
    def test_mdtr_no_data(self):
        """ Test the mdtr script without the appropriate data in the
        database.
        """
        command = self.command[:]

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        self.assertEqual(stderr, '')
        self.assertEqual(
            stdout,
            "Category 'Fedora Linux' not found, exiting\n"
            "Available categories:\n")

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, 'Version 20 not found for product Fedora\n')
        self.assertEqual(stderr, '')

        # One step further
        tests.create_version(self.session)

        process = subprocess.Popen(
            args=command,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout,
            'directory pub/fedora/linux/releases/20/Fedora/i386/os does not '
            'exist on disk, skipping creation of a repository there\n'
            'directory pub/fedora-secondary/releases/20/Fedora/ppc/os does '
            'not exist on disk, skipping creation of a repository there\n'
            'directory pub/fedora/linux/releases/20/Fedora/x86_64/os does '
            'not exist on disk, skipping creation of a repository there\n')
        self.assertEqual(stderr, '')

        process = subprocess.Popen(
            args=command[:] + ['--test'],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout,
            'directory pub/fedora/linux/releases/20/Fedora/i386/os exists on'
            ' disk, but not in the database yet, skipping creation of a '
            'repository there until after the next UMDL run.\n'
            'directory pub/fedora-secondary/releases/20/Fedora/ppc/os exists '
            'on disk, but not in the database yet, skipping creation of a '
            'repository there until after the next UMDL run.\n'
            'directory pub/fedora/linux/releases/20/Fedora/x86_64/os exists '
            'on disk, but not in the database yet, skipping creation of a '
            'repository there until after the next UMDL run.\n')
        self.assertEqual(stderr, '')
コード例 #39
0
ファイル: test_mdtr.py プロジェクト: nphilipp/mirrormanager2
    def test_mdtr(self):
        """ Test the mdtr script. """
        command = self.command[:]

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)
        tests.create_version(self.session)

        item = model.Directory(
            name='pub/fedora/linux/releases/26/Everything/x86_64/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/releases/26/Everything/armhfp/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora-secondary/releases/26/Everything/ppc64le/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora-secondary/releases/26/Everything/sources/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/development/27/Everything/x86_64/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/releases/27/Everything/x86_64/os',
            readable=True,
        )
        self.session.add(item)

        item = model.Repository(
            name='pub/fedora/linux/development/27/Everything/x86_64/os',
            prefix='fedora-27',
            version_id=3,
            arch_id=3,
            directory_id=14,
            category_id=1,
        )
        self.session.add(item)
        item = model.Repository(
            name='pub/fedora/linux/releases/26/Everything/x86_64/os',
            prefix=None,
            version_id=1,
            arch_id=3,
            directory_id=10,
            category_id=1,
        )
        self.session.add(item)

        item = model.Category(
            name='Fedora Secondary Arches',
            product_id=2,
            canonicalhost='http://download.fedora.redhat.com',
            topdir_id=1,
            publiclist=True)
        self.session.add(item)

        self.session.commit()

        # Check before running the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 2)

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 6 more here, 9+6=15
        self.assertEqual(len(results), 15)
        self.assertEqual(results[9].name,
                         'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(results[10].name,
                         'pub/fedora/linux/releases/26/Everything/armhfp/os')
        self.assertEqual(
            results[11].name,
            'pub/fedora-secondary/releases/26/Everything/ppc64le/os')
        self.assertEqual(
            results[12].name,
            'pub/fedora-secondary/releases/26/Everything/sources/os')
        self.assertEqual(
            results[13].name,
            'pub/fedora/linux/development/27/Everything/x86_64/os')
        self.assertEqual(results[14].name,
                         'pub/fedora/linux/releases/27/Everything/x86_64/os')

        # Run the script

        process = subprocess.Popen(args=command[:],
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout, 'pub/fedora/linux/development/27/Everything/x86_64/os '
            '=> pub/fedora/linux/releases/27/Everything/x86_64/os\n')
        self.assertEqual(stderr, '')

        # Check after running the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 2)

        res = results[0]
        self.assertEqual(res.prefix, 'fedora-27')
        self.assertEqual(res.name,
                         'pub/fedora/linux/releases/27/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '27')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(res.directory.name,
                         'pub/fedora/linux/releases/27/Everything/x86_64/os')

        res = results[1]
        self.assertEqual(res.prefix, None)
        self.assertEqual(res.name,
                         'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '26')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(res.directory.name,
                         'pub/fedora/linux/releases/26/Everything/x86_64/os')

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 6 more here, 9+6=15
        self.assertEqual(len(results), 15)
        self.assertEqual(results[9].name,
                         'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(results[10].name,
                         'pub/fedora/linux/releases/26/Everything/armhfp/os')
        self.assertEqual(
            results[11].name,
            'pub/fedora-secondary/releases/26/Everything/ppc64le/os')
        self.assertEqual(
            results[12].name,
            'pub/fedora-secondary/releases/26/Everything/sources/os')
        self.assertEqual(
            results[13].name,
            'pub/fedora/linux/development/27/Everything/x86_64/os')
        self.assertEqual(results[14].name,
                         'pub/fedora/linux/releases/27/Everything/x86_64/os')

        # Check non-existing version

        command = ('%s -c %s --version=24 '
                   '--category=' % (self.script, self.configfile)).split()
        command[-1] += 'Fedora Linux'

        process = subprocess.Popen(args=command[:],
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, 'Version 24 not found for product Fedora\n')
        self.assertEqual(stderr, '')

        # Check after running the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 2)

        res = results[0]
        self.assertEqual(res.prefix, 'fedora-27')
        self.assertEqual(res.name,
                         'pub/fedora/linux/releases/27/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '27')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(res.directory.name,
                         'pub/fedora/linux/releases/27/Everything/x86_64/os')

        res = results[1]
        self.assertEqual(res.prefix, None)
        self.assertEqual(res.name,
                         'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '26')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(res.directory.name,
                         'pub/fedora/linux/releases/26/Everything/x86_64/os')

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 6 more here, 9+6=15
        self.assertEqual(len(results), 15)
        self.assertEqual(results[9].name,
                         'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(results[10].name,
                         'pub/fedora/linux/releases/26/Everything/armhfp/os')
        self.assertEqual(
            results[11].name,
            'pub/fedora-secondary/releases/26/Everything/ppc64le/os')
        self.assertEqual(
            results[12].name,
            'pub/fedora-secondary/releases/26/Everything/sources/os')
        self.assertEqual(
            results[13].name,
            'pub/fedora/linux/development/27/Everything/x86_64/os')
        self.assertEqual(results[14].name,
                         'pub/fedora/linux/releases/27/Everything/x86_64/os')
コード例 #40
0
    def test_mdtr(self):
        """ Test the mdtr script. """
        command = self.command[:]

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)
        tests.create_version(self.session)

        item = model.Directory(
            name='pub/fedora/linux/releases/20/Fedora/x86_64/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/releases/20/Fedora/i386/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora-secondary/releases/20/Fedora/ppc/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora-secondary/releases/20/Fedora/sources/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/development/21/x86_64/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/releases/21/Fedora/x86_64/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/releases/21/Everything/x86_64/os',
            readable=True,
        )
        self.session.add(item)

        item = model.Repository(
            name='pub/fedora/linux/development/21/x86_64/os',
            prefix='fedora-21',
            version_id=3,
            arch_id=3,
            directory_id=14,
            category_id=1,
        )
        self.session.add(item)
        item = model.Repository(
            name='pub/fedora/linux/releases/21/Everything/x86_64/os',
            prefix=None,
            version_id=3,
            arch_id=3,
            directory_id=16,
            category_id=1,
        )
        self.session.add(item)

        item = model.Category(
            name='Fedora Secondary Arches',
            product_id=2,
            canonicalhost='http://download.fedora.redhat.com',
            topdir_id=1,
            publiclist=True
        )
        self.session.add(item)

        self.session.commit()

        # Check before running the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 2)

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 7 more here, 9+7=16
        self.assertEqual(len(results), 16)
        self.assertEqual(
            results[9].name,
            'pub/fedora/linux/releases/20/Fedora/x86_64/os')
        self.assertEqual(
            results[10].name,
            'pub/fedora/linux/releases/20/Fedora/i386/os')
        self.assertEqual(
            results[11].name,
            'pub/fedora-secondary/releases/20/Fedora/ppc/os')
        self.assertEqual(
            results[12].name,
            'pub/fedora-secondary/releases/20/Fedora/sources/os')
        self.assertEqual(
            results[13].name,
            'pub/fedora/linux/development/21/x86_64/os')
        self.assertEqual(
            results[14].name,
            'pub/fedora/linux/releases/21/Fedora/x86_64/os')
        self.assertEqual(
            results[15].name,
            'pub/fedora/linux/releases/21/Everything/x86_64/os')

        # Run the script

        process = subprocess.Popen(
            args=command[:] + ['--test'],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout,
            'updating fedora-install-20 repo for arch i386\n'
            'updating fedora-install-20 repo for arch ppc\n'
            'updating fedora-install-20 repo for arch x86_64\n'
        )
        self.assertEqual(stderr, '')

        # Check after running the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 5)

        res = results[0]
        self.assertEqual(res.prefix, 'fedora-21')
        self.assertEqual(
            res.name, 'pub/fedora/linux/development/21/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '21')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/development/21/x86_64/os')

        res = results[1]
        self.assertEqual(res.prefix, None)
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/21/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '21')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/21/Everything/x86_64/os')

        res = results[2]
        self.assertEqual(res.prefix, 'fedora-install-20')
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/20/Fedora/i386/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '20')
        self.assertEqual(res.arch.name, 'i386')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/20/Fedora/i386/os')

        res = results[3]
        self.assertEqual(res.prefix, 'fedora-install-20')
        self.assertEqual(
            res.name, 'pub/fedora-secondary/releases/20/Fedora/ppc/os')
        self.assertEqual(res.category.name, 'Fedora Secondary Arches')
        self.assertEqual(res.version.name, '20')
        self.assertEqual(res.arch.name, 'ppc')
        self.assertEqual(
            res.directory.name,
            'pub/fedora-secondary/releases/20/Fedora/ppc/os')

        res = results[4]
        self.assertEqual(res.prefix, 'fedora-install-20')
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/20/Fedora/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '20')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/20/Fedora/x86_64/os')

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 7 more here, 9+7=16
        self.assertEqual(len(results), 16)
        self.assertEqual(
            results[9].name,
            'pub/fedora/linux/releases/20/Fedora/x86_64/os')
        self.assertEqual(
            results[10].name,
            'pub/fedora/linux/releases/20/Fedora/i386/os')
        self.assertEqual(
            results[11].name,
            'pub/fedora-secondary/releases/20/Fedora/ppc/os')
        self.assertEqual(
            results[12].name,
            'pub/fedora-secondary/releases/20/Fedora/sources/os')
        self.assertEqual(
            results[13].name,
            'pub/fedora/linux/development/21/x86_64/os')
        self.assertEqual(
            results[14].name,
            'pub/fedora/linux/releases/21/Fedora/x86_64/os')
        self.assertEqual(
            results[15].name,
            'pub/fedora/linux/releases/21/Everything/x86_64/os')

        # Update F21

        command = ('%s -c %s --version=21 '\
            '--category=' % (self.script, self.configfile)).split()
        command[-1] += 'Fedora Linux'

        process = subprocess.Popen(
            args=command[:] + ['--test'],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()
        print stdout

        self.assertEqual(
            stdout,
            'pub/fedora/linux/development/21/x86_64/os => '
            'pub/fedora/linux/releases/21/Everything/x86_64/os\n'
            'directory pub/fedora/linux/releases/21/Fedora/i386/os exists '
            'on disk, but not in the database yet, skipping creation of a '
            'repository there until after the next UMDL run.\n'
            'directory pub/fedora-secondary/releases/21/Fedora/ppc/os exists '
            'on disk, but not in the database yet, skipping creation of a '
            'repository there until after the next UMDL run.\n'
            'updating fedora-install-21 repo for arch x86_64\n'
        )
        self.assertEqual(stderr, '')

        # Check after running the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 6)

        res = results[0]
        self.assertEqual(res.prefix, 'fedora-21')
        self.assertEqual(
            res.name, 'pub/fedora/linux/development/21/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '21')
        self.assertEqual(res.arch, None)
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/development/21/x86_64/os')

        res = results[1]
        self.assertEqual(res.prefix, 'fedora-21')
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/21/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '21')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/21/Everything/x86_64/os')

        res = results[2]
        self.assertEqual(res.prefix, 'fedora-install-20')
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/20/Fedora/i386/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '20')
        self.assertEqual(res.arch.name, 'i386')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/20/Fedora/i386/os')

        res = results[3]
        self.assertEqual(res.prefix, 'fedora-install-20')
        self.assertEqual(
            res.name, 'pub/fedora-secondary/releases/20/Fedora/ppc/os')
        self.assertEqual(res.category.name, 'Fedora Secondary Arches')
        self.assertEqual(res.version.name, '20')
        self.assertEqual(res.arch.name, 'ppc')
        self.assertEqual(
            res.directory.name,
            'pub/fedora-secondary/releases/20/Fedora/ppc/os')

        res = results[4]
        self.assertEqual(res.prefix, 'fedora-install-20')
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/20/Fedora/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '20')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/20/Fedora/x86_64/os')

        res = results[5]
        self.assertEqual(res.prefix, 'fedora-install-21')
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/21/Fedora/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '21')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/21/Fedora/x86_64/os')

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 7 more here, 9+7=16
        self.assertEqual(len(results), 16)
        self.assertEqual(
            results[9].name,
            'pub/fedora/linux/releases/20/Fedora/x86_64/os')
        self.assertEqual(
            results[10].name,
            'pub/fedora/linux/releases/20/Fedora/i386/os')
        self.assertEqual(
            results[11].name,
            'pub/fedora-secondary/releases/20/Fedora/ppc/os')
        self.assertEqual(
            results[12].name,
            'pub/fedora-secondary/releases/20/Fedora/sources/os')
        self.assertEqual(
            results[13].name,
            'pub/fedora/linux/development/21/x86_64/os')
        self.assertEqual(
            results[14].name,
            'pub/fedora/linux/releases/21/Fedora/x86_64/os')
        self.assertEqual(
            results[15].name,
            'pub/fedora/linux/releases/21/Everything/x86_64/os')
コード例 #41
0
ファイル: test_umdl.py プロジェクト: nirik/mirrormanager2
    def test_1_umdl(self):
        """ Test the umdl cron. """

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        # Run the UDML

        process = subprocess.Popen(args=self.umdl_command.split(),
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, '')
        self.assertEqual(stderr, '')

        with open(self.logfile) as stream:
            logs = stream.readlines()
        #self.assertEqual(len(logs), 3)
        logs = ''.join([log.split(' ', 3)[-1] for log in logs])
        print logs
        exp = """umdl_master_directories Category Fedora Secondary Arches does not exist in the database, skipping
umdl_master_directories Category Fedora Archive does not exist in the database, skipping
umdl_master_directories Category Fedora Other does not exist in the database, skipping
"""
        self.assertEqual(logs, exp)

        # The DB should now be filled with what UMDL added, so let's check it
        results = mirrormanager2.lib.query_directories(self.session)
        self.assertEqual(len(results), 0)

        results = mirrormanager2.lib.get_versions(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'development')
        self.assertEqual(results[0].product.name, 'Fedora')
        self.assertEqual(results[1].name, '21')
        self.assertEqual(results[1].product.name, 'Fedora')

        results = mirrormanager2.lib.get_categories(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'Fedora Linux')
        self.assertEqual(results[1].name, 'Fedora EPEL')

        results = mirrormanager2.lib.get_products(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'EPEL')
        self.assertEqual(results[1].name, 'Fedora')

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name,
                         'pub/fedora/linux/releases/atomic/rawhide')
        self.assertEqual(results[0].category.name, 'Fedora Linux')
        self.assertEqual(results[0].version.name, 'development')
        self.assertEqual(results[0].arch.name, 'x86_64')
        self.assertEqual(results[0].directory.name,
                         'pub/fedora/linux/releases/atomic/rawhide')
        self.assertEqual(results[0].prefix, 'atomic-unknown')

        self.assertEqual(results[1].name,
                         'pub/fedora/linux/releases/atomic/21')
        self.assertEqual(results[1].category.name, 'Fedora Linux')
        self.assertEqual(results[1].version.name, '21')
        self.assertEqual(results[1].arch.name, 'x86_64')
        self.assertEqual(results[1].directory.name,
                         'pub/fedora/linux/releases/atomic/21')
        self.assertEqual(results[1].prefix, 'atomic-21')

        results = mirrormanager2.lib.get_arches(self.session)
        self.assertEqual(len(results), 4)
        self.assertEqual(results[0].name, 'i386')
        self.assertEqual(results[1].name, 'ppc')
        self.assertEqual(results[2].name, 'source')
        self.assertEqual(results[3].name, 'x86_64')

        results = mirrormanager2.lib.get_directories(self.session)
        # tree testdata/pub says there are 84 directories and 150 files
        # There are 7 directories added by create_directory which are not
        # present on the FS, 84 + 7 = 91, so we are good \ó/
        self.assertEqual(len(results), 91)
        self.assertEqual(results[0].name, 'pub/fedora/linux/releases')
        self.assertEqual(results[1].name, 'pub/fedora/linux/extras')
        self.assertEqual(results[2].name, 'pub/epel')
        self.assertEqual(results[3].name, 'pub/fedora/linux/releases/20')
        self.assertEqual(results[4].name, 'pub/fedora/linux/releases/21')
        self.assertEqual(results[5].name,
                         'pub/archive/fedora/linux/releases/20/Fedora/source')
        self.assertEqual(
            results[20].name,
            'pub/fedora/linux/releases/atomic/21/refs/heads/fedora-atomic/f21')
        self.assertEqual(
            results[21].name, 'pub/fedora/linux/releases/atomic/21/refs/heads/'
            'fedora-atomic/f21/x86_64')
        self.assertEqual(
            results[22].name, 'pub/fedora/linux/releases/atomic/21/refs/heads/'
            'fedora-atomic/f21/x86_64/updates')
        self.assertEqual(results[23].name,
                         'pub/fedora/linux/releases/atomic/21/refs/remotes')
        self.assertEqual(results[24].name,
                         'pub/fedora/linux/releases/atomic/21/remote-cache')

        results = mirrormanager2.lib.get_file_detail(self.session,
                                                     'repomd.xml', 7)
        self.assertEqual(results, None)

        results = mirrormanager2.lib.get_file_details(self.session)
        self.assertEqual(len(results), 9)

        cnt = 0
        self.assertEqual(results[cnt].filename, 'Fedora-20-x86_64-DVD.iso')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Fedora/x86_64/iso')
        self.assertEqual(results[cnt].sha512, None)
        self.assertEqual(
            results[cnt].sha256,
            'f2eeed5102b8890e9e6f4b9053717fe73031e699c4b76dc7028749ab66e7f917')

        cnt = 1
        self.assertEqual(results[cnt].filename, 'Fedora-20-x86_64-netinst.iso')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Fedora/x86_64/iso')
        self.assertEqual(results[cnt].sha512, None)
        self.assertEqual(
            results[cnt].sha256,
            '376be7d4855ad6281cb139430606a782fd6189dcb01d7b61448e915802cc350f')

        cnt = 2
        self.assertEqual(results[cnt].filename,
                         'Fedora-Live-Desktop-x86_64-20-1.iso')
        self.assertEqual(results[cnt].directory.name,
                         'pub/fedora/linux/releases/releases/20/Live/x86_64')
        self.assertEqual(results[cnt].sha512, None)
        self.assertEqual(
            results[cnt].sha256,
            'cc0333be93c7ff2fb3148cb29360d2453f78913cc8aa6c6289ae6823372a77d2')

        cnt = 3
        self.assertEqual(results[cnt].filename,
                         'Fedora-Live-KDE-x86_64-20-1.iso')
        self.assertEqual(results[cnt].directory.name,
                         'pub/fedora/linux/releases/releases/20/Live/x86_64')
        self.assertEqual(results[cnt].sha512, None)
        self.assertEqual(
            results[cnt].sha256,
            '08360a253b4a40dff948e568dba1d2ae9d931797f57aa08576b8b9f1ef7e4745')

        cnt = 4
        self.assertEqual(results[cnt].filename, 'repomd.xml')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/development/22/x86_64/os/repodata')
        self.assertEqual(
            results[cnt].sha256,
            '108b4102829c0839c7712832577fe7da24f0a9491f4dc25d4145efe6aced2ebf')
        self.assertEqual(
            results[cnt].sha512,
            '50ed8cb8f4daf8bcd1d0ccee1710b8a87ee8de5861fb15a1023d6558328795'
            'f42dade3e025c09c20ade36c77a3a82d9cdce1a2e2ad171f9974bc1889b591'
            '8020')

        cnt = 5
        self.assertEqual(results[cnt].filename, 'summary')
        self.assertEqual(results[cnt].directory.name,
                         'pub/fedora/linux/releases/atomic/rawhide')
        self.assertEqual(
            results[cnt].sha256,
            '6b439b70ecb1941e0e2e0ea0817a66715067cbd96d4367f4cd23ca287aeb14cb')
        self.assertEqual(
            results[cnt].sha512,
            '6f3cafa7f16b796a6051f740de17344542feb8b2285e3ccd9b141217fbb5f0'
            'b602c2389e4a40fe3b1aeac6f853b4c6d2d6c863e3649f567bd1af2aea502f'
            'd9e8')

        cnt = 6
        self.assertEqual(results[cnt].filename, 'summary')
        self.assertEqual(results[cnt].directory.name,
                         'pub/fedora/linux/releases/atomic/21')
        self.assertEqual(
            results[cnt].sha256,
            '6b439b70ecb1941e0e2e0ea0817a66715067cbd96d4367f4cd23ca287aeb14cb')
        self.assertEqual(
            results[cnt].sha512,
            '6f3cafa7f16b796a6051f740de17344542feb8b2285e3ccd9b141217fbb5f0'
            'b602c2389e4a40fe3b1aeac6f853b4c6d2d6c863e3649f567bd1af2aea502f'
            'd9e8')

        cnt = 7
        self.assertEqual(results[cnt].filename, 'repomd.xml')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Fedora/source/SRPMS/repodata'
        )
        self.assertEqual(
            results[cnt].sha256,
            '9a4738934092cf17e4540ee9cab741e922eb8306875ae5621feb01ebeb1f67f2')
        self.assertEqual(
            results[cnt].sha512,
            '3351c7a6b1d2bd94e375d09324a9280b8becfe4dea40a227c3b270ddcedb19'
            'f420eec3f2c6a39a1edcdf52f80d31eb47a0ba25057ced2e3182dd212bc746'
            '6ba2')

        cnt = 8
        self.assertEqual(results[cnt].filename, 'repomd.xml')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Fedora/x86_64/os/repodata')
        self.assertEqual(
            results[cnt].sha256,
            '108b4102829c0839c7712832577fe7da24f0a9491f4dc25d4145efe6aced2ebf')
        self.assertEqual(
            results[cnt].sha512,
            '50ed8cb8f4daf8bcd1d0ccee1710b8a87ee8de5861fb15a1023d6558328795'
            'f42dade3e025c09c20ade36c77a3a82d9cdce1a2e2ad171f9974bc1889b591'
            '8020')

        results = mirrormanager2.lib.get_host_category_dirs(self.session)
        self.assertEqual(len(results), 0)
コード例 #42
0
    def test_1_umdl(self):
        """ Test the umdl cron. """

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        # Run the UDML

        process = subprocess.Popen(
            args=self.umdl_command.split(),
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, '')
        self.assertEqual(stderr, '')

        with open(self.logfile) as stream:
            logs = stream.readlines()
        logs = ''.join([
            log.split(':', 3)[-1]
            for log in logs
        ])

        for i in [
                'N/A:Starting umdl',
                'Fedora Linux: has changed: 0 !=',
                'Fedora Linux:development has changed: 0 !=',
                'Fedora Linux:releases/20/Fedora has changed: 0 !=',
                'Fedora/source/SRPMS/r has changed: 0 !=',
                'releases/20/Fedora/x86_64/iso has changed: 0 !=',
                'releases/20/Live/x86_64 has changed: 0 !=',
                'Fedora Linux:Updating FileDetail <mirrormanager2.lib.model',
                'Created Version(product=<Product(2 - Fedora)>',
                'Version(product=<Product(2 - Fedora)>, name=20',
                'Repository(prefix=None, version=20, arch=source',
                'ategory Fedora Secondary Arches does not exist',
                'Fedora Other:Refresh the list of repomd.xml'
        ]:
            self.assertTrue(i in logs)

        # The DB should now be filled with what UMDL added, so let's check it
        results = mirrormanager2.lib.query_directories(self.session)
        self.assertEqual(len(results), 0)

        results = mirrormanager2.lib.get_versions(self.session)
        self.assertEqual(len(results), 2)
        for result in results:
            version_names = [ '22', '20' ]
            self.assertTrue(result.name in version_names)
            if result.name == '22':
                self.assertEqual(result.product.name, 'Fedora')
            if result.name == '20':
                self.assertEqual(result.product.name, 'Fedora')

        results = mirrormanager2.lib.get_categories(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'Fedora Linux')
        self.assertEqual(results[1].name, 'Fedora EPEL')

        results = mirrormanager2.lib.get_products(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'EPEL')
        self.assertEqual(results[1].name, 'Fedora')

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 3)
        check_counter = 0
        for result in results:
            if result.name == 'pub/fedora/linux/development/22/x86_64/os':
                self.assertEqual(result.category.name, 'Fedora Linux')
                self.assertEqual(result.version.name, '22')
                self.assertEqual(result.arch.name, 'x86_64')
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/development/22/x86_64/os')
                self.assertEqual(result.prefix, None)
                check_counter += 1
            if result.name == 'pub/fedora/linux/releases/20/Fedora/x86_64/os':
                self.assertEqual(result.category.name, 'Fedora Linux')
                self.assertEqual(result.version.name, '20')
                self.assertEqual(result.arch.name, 'x86_64')
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/x86_64/os')
                self.assertEqual(result.prefix, 'fedora-install-20')
                check_counter += 1

        self.assertEqual(check_counter, 2)

        results = mirrormanager2.lib.get_arches(self.session)
        self.assertEqual(len(results), 4)
        self.assertEqual(results[0].name, 'i386')
        self.assertEqual(results[1].name, 'ppc')
        self.assertEqual(results[2].name, 'source')
        self.assertEqual(results[3].name, 'x86_64')

        results = mirrormanager2.lib.get_directories(self.session)
        # tree testdata/pub says there are 49 directories and 49 files
        # There are 7 directories added by create_directory which are not
        # present on the FS, 49 + 7 = 56, so we are good \ó/
        self.assertEqual(len(results), 56)
        self.assertEqual(results[0].name, 'pub/fedora/linux')
        self.assertEqual(results[1].name, 'pub/fedora/linux/extras')
        self.assertEqual(results[2].name, 'pub/epel')
        self.assertEqual(results[3].name, 'pub/fedora/linux/releases/26')
        self.assertEqual(results[4].name, 'pub/fedora/linux/releases/27')
        self.assertEqual(
            results[5].name,
            'pub/archive/fedora/linux/releases/26/Everything/source')
        self.assertEqual(
            results[20].name,
            'pub/fedora/linux/releases/20/Fedora/source/SRPMS/b')

        results = mirrormanager2.lib.get_file_detail(
            self.session, 'repomd.xml', 7)
        self.assertEqual(results, None)

        results = mirrormanager2.lib.get_file_details(self.session)
        self.assertEqual(len(results), 7)

        check_counter = 0
        for result in results:
            if result.filename == 'Fedora-20-x86_64-DVD.iso':
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/x86_64/iso')
                self.assertEqual(result.sha512, None)
                self.assertEqual(
                    result.sha256,
                    'f2eeed5102b8890e9e6f4b9053717fe73031e699c4b76dc7028749ab66e7f917')
                check_counter += 1

            elif result.filename == 'Fedora-20-x86_64-netinst.iso':
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/x86_64/iso')
                self.assertEqual(result.sha512, None)
                self.assertEqual(
                    result.sha256,
                    '376be7d4855ad6281cb139430606a782fd6189dcb01d7b61448e915802cc350f')
                check_counter += 1

            elif result.filename == 'Fedora-Live-Desktop-x86_64-20-1.iso':
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Live/x86_64')
                self.assertEqual(result.sha512, None)
                self.assertEqual(
                    result.sha256,
                    'cc0333be93c7ff2fb3148cb29360d2453f78913cc8aa6c6289ae6823372a77d2')
                check_counter += 1

            elif result.filename == 'Fedora-Live-KDE-x86_64-20-1.iso':
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Live/x86_64')
                self.assertEqual(result.sha512, None)
                self.assertEqual(
                    result.sha256,
                    '08360a253b4a40dff948e568dba1d2ae9d931797f57aa08576b8b9f1ef7e4745')
                check_counter += 1

            elif result.md5 == 'd0fb87891c3bfbdaf7a225f57e9ba6ee':
                self.assertEqual(result.filename, 'repomd.xml')
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/development/22/x86_64/os/repodata')
                self.assertEqual(
                    result.sha256,
                    '860f0f832f7a641cf8f7e27172ef9b2492ce849388e43f372af7e512aa646677')
                self.assertEqual(
                    result.sha512,
                    '7bb9a0bae076ccbbcd086163a1d4f33b62321aa6991d135c42bf3f6c42c4eb'
                    '465a0b42c62efa809708543fcd69511cb19cd7111d5ff295a50253b9c7659b'
                    'b9d6')
                check_counter += 1

            elif result.md5 == '082970dfa804fdcfaed2e15e2e5fba7d':
                self.assertEqual(result.filename, 'repomd.xml')
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/source/SRPMS/repodata')
                self.assertEqual(
                    result.sha256,
                    '9a4738934092cf17e4540ee9cab741e922eb8306875ae5621feb01ebeb1f67f2')
                self.assertEqual(
                    result.sha512,
                    '3351c7a6b1d2bd94e375d09324a9280b8becfe4dea40a227c3b270ddcedb19'
                    'f420eec3f2c6a39a1edcdf52f80d31eb47a0ba25057ced2e3182dd212bc746'
                    '6ba2')
                check_counter += 1

            elif result.md5 == '49db42c616518f465014c3605de4414d':
                self.assertEqual(result.filename, 'repomd.xml')
                self.assertEqual(
                    result.directory.name,
                    'pub/fedora/linux/releases/20/Fedora/x86_64/os/repodata')
                self.assertEqual(
                    result.sha256,
                    '108b4102829c0839c7712832577fe7da24f0a9491f4dc25d4145efe6aced2ebf')
                self.assertEqual(
                    result.sha512,
                    '50ed8cb8f4daf8bcd1d0ccee1710b8a87ee8de5861fb15a1023d6558328795'
                    'f42dade3e025c09c20ade36c77a3a82d9cdce1a2e2ad171f9974bc1889b591'
                    '8020')
                check_counter += 1

        self.assertEqual(check_counter, 7)

        results = mirrormanager2.lib.get_host_category_dirs(self.session)
        self.assertEqual(len(results), 0)
コード例 #43
0
    def test_get_mirrors(self):
        """ Test the get_mirrors function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_mirrors(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)
        tests.create_categorydirectory(self.session)
        tests.create_netblockcountry(self.session)

        results = mirrormanager2.lib.get_mirrors(self.session)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session, private=True)
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].name, 'private.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session, internet2=True)
        self.assertEqual(len(results), 0)

        results = mirrormanager2.lib.get_mirrors(
            self.session, internet2_clients=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, internet2_clients=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, asn_clients=True)
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        results = mirrormanager2.lib.get_mirrors(
            self.session, asn_clients=False)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'private.localhost')
        self.assertEqual(results[1].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, admin_active=False)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, admin_active=True)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, user_active=False)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, user_active=True)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, host_category_url_private=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, host_category_url_private=False)
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, last_crawl_duration=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, last_crawl_duration=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, last_crawled=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, last_crawled=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, last_checked_in=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, last_checked_in=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, site_private=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, site_private=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, site_user_active=False)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, site_user_active=True)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, site_admin_active=False)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, site_admin_active=True)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, up2date=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, up2date=False)
        self.assertEqual(len(results), 0)

        results = mirrormanager2.lib.get_mirrors(
            self.session, version_id=1)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, version_id=3)

        tests.create_version(self.session)
        tests.create_repository(self.session)

        results = mirrormanager2.lib.get_mirrors(
            self.session, version_id=1)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'mirror.localhost')
        results = mirrormanager2.lib.get_mirrors(
            self.session, version_id=3)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, arch_id=1)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, arch_id=3)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'mirror.localhost')
コード例 #44
0
    def test_mdtr(self):
        """ Test the mdtr script. """
        command = self.command[:]

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)
        tests.create_version(self.session)

        item = model.Directory(
            name='pub/fedora/linux/releases/26/Everything/x86_64/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/releases/26/Everything/armhfp/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora-secondary/releases/26/Everything/ppc64le/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora-secondary/releases/26/Everything/sources/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/development/27/Everything/x86_64/os',
            readable=True,
        )
        self.session.add(item)
        item = model.Directory(
            name='pub/fedora/linux/releases/27/Everything/x86_64/os',
            readable=True,
        )
        self.session.add(item)

        item = model.Repository(
            name='pub/fedora/linux/development/27/Everything/x86_64/os',
            prefix='fedora-27',
            version_id=3,
            arch_id=3,
            directory_id=14,
            category_id=1,
        )
        self.session.add(item)
        item = model.Repository(
            name='pub/fedora/linux/releases/26/Everything/x86_64/os',
            prefix=None,
            version_id=1,
            arch_id=3,
            directory_id=10,
            category_id=1,
        )
        self.session.add(item)

        item = model.Category(
            name='Fedora Secondary Arches',
            product_id=2,
            canonicalhost='http://download.fedora.redhat.com',
            topdir_id=1,
            publiclist=True
        )
        self.session.add(item)

        self.session.commit()

        # Check before running the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 2)

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 6 more here, 9+6=15
        self.assertEqual(len(results), 15)
        self.assertEqual(
            results[9].name,
            'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(
            results[10].name,
            'pub/fedora/linux/releases/26/Everything/armhfp/os')
        self.assertEqual(
            results[11].name,
            'pub/fedora-secondary/releases/26/Everything/ppc64le/os')
        self.assertEqual(
            results[12].name,
            'pub/fedora-secondary/releases/26/Everything/sources/os')
        self.assertEqual(
            results[13].name,
            'pub/fedora/linux/development/27/Everything/x86_64/os')
        self.assertEqual(
            results[14].name,
            'pub/fedora/linux/releases/27/Everything/x86_64/os')

        # Run the script

        process = subprocess.Popen(
            args=command[:],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout,
            'pub/fedora/linux/development/27/Everything/x86_64/os '
            '=> pub/fedora/linux/releases/27/Everything/x86_64/os\n'
        )
        self.assertEqual(stderr, '')

        # Check after running the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 2)

        res = results[0]
        self.assertEqual(res.prefix, 'fedora-27')
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/27/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '27')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/27/Everything/x86_64/os')

        res = results[1]
        self.assertEqual(res.prefix, None)
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '26')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/26/Everything/x86_64/os')

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 6 more here, 9+6=15
        self.assertEqual(len(results), 15)
        self.assertEqual(
            results[9].name,
            'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(
            results[10].name,
            'pub/fedora/linux/releases/26/Everything/armhfp/os')
        self.assertEqual(
            results[11].name,
            'pub/fedora-secondary/releases/26/Everything/ppc64le/os')
        self.assertEqual(
            results[12].name,
            'pub/fedora-secondary/releases/26/Everything/sources/os')
        self.assertEqual(
            results[13].name,
            'pub/fedora/linux/development/27/Everything/x86_64/os')
        self.assertEqual(
            results[14].name,
            'pub/fedora/linux/releases/27/Everything/x86_64/os')

        # Check non-existing version

        command = ('%s -c %s --version=24 '
                   '--category=' % (self.script, self.configfile)).split()
        command[-1] += 'Fedora Linux'

        process = subprocess.Popen(
            args=command[:],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout,
            'Version 24 not found for product Fedora\n'
        )
        self.assertEqual(stderr, '')

        # Check after running the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 2)

        res = results[0]
        self.assertEqual(res.prefix, 'fedora-27')
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/27/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '27')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/27/Everything/x86_64/os')

        res = results[1]
        self.assertEqual(res.prefix, None)
        self.assertEqual(
            res.name, 'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(res.category.name, 'Fedora Linux')
        self.assertEqual(res.version.name, '26')
        self.assertEqual(res.arch.name, 'x86_64')
        self.assertEqual(
            res.directory.name,
            'pub/fedora/linux/releases/26/Everything/x86_64/os')

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 6 more here, 9+6=15
        self.assertEqual(len(results), 15)
        self.assertEqual(
            results[9].name,
            'pub/fedora/linux/releases/26/Everything/x86_64/os')
        self.assertEqual(
            results[10].name,
            'pub/fedora/linux/releases/26/Everything/armhfp/os')
        self.assertEqual(
            results[11].name,
            'pub/fedora-secondary/releases/26/Everything/ppc64le/os')
        self.assertEqual(
            results[12].name,
            'pub/fedora-secondary/releases/26/Everything/sources/os')
        self.assertEqual(
            results[13].name,
            'pub/fedora/linux/development/27/Everything/x86_64/os')
        self.assertEqual(
            results[14].name,
            'pub/fedora/linux/releases/27/Everything/x86_64/os')
コード例 #45
0
    def test_get_mirrors(self):
        """ Test the get_mirrors function of mirrormanager2.lib.
        """
        results = mirrormanager2.lib.get_mirrors(self.session)
        self.assertEqual(results, [])

        tests.create_base_items(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_hostcategory(self.session)
        tests.create_hostcategoryurl(self.session)
        tests.create_categorydirectory(self.session)
        tests.create_netblockcountry(self.session)

        results = mirrormanager2.lib.get_mirrors(self.session)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session, private=True)
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].name, 'private.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session, internet2=True)
        self.assertEqual(len(results), 0)

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 internet2_clients=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 internet2_clients=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 asn_clients=True)
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 asn_clients=False)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'private.localhost')
        self.assertEqual(results[1].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 admin_active=False)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 admin_active=True)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 user_active=False)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 user_active=True)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(
            self.session, host_category_url_private=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(
            self.session, host_category_url_private=False)
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 last_crawl_duration=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 last_crawl_duration=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 last_crawled=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 last_crawled=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 last_checked_in=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 last_checked_in=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 site_private=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 site_private=False)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 site_user_active=False)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 site_user_active=True)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 site_admin_active=False)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session,
                                                 site_admin_active=True)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'private.localhost')
        self.assertEqual(results[2].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session, up2date=True)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session, up2date=False)
        self.assertEqual(len(results), 0)

        results = mirrormanager2.lib.get_mirrors(self.session, version_id=1)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session, version_id=3)

        tests.create_version(self.session)
        tests.create_repository(self.session)

        results = mirrormanager2.lib.get_mirrors(self.session, version_id=1)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'mirror.localhost')
        results = mirrormanager2.lib.get_mirrors(self.session, version_id=3)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'mirror.localhost')

        results = mirrormanager2.lib.get_mirrors(self.session, arch_id=1)
        self.assertEqual(len(results), 0)
        results = mirrormanager2.lib.get_mirrors(self.session, arch_id=3)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'mirror2.localhost')
        self.assertEqual(results[1].name, 'mirror.localhost')
コード例 #46
0
    def test_mta(self):
        """ Test the mta script. """
        command = self.command[:]

        process = subprocess.Popen(args=command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(stderr, '')
        self.assertEqual(
            stdout, "No category could be found by the name: Fedora Linux\n")

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)
        tests.create_version(self.session)
        tests.create_repository(self.session)

        process = subprocess.Popen(args=command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout, 'No category could be found by the name: Fedora Archive\n')
        self.assertEqual(stderr, '')

        # One step further
        item = model.Directory(
            name='pub/archive',
            readable=True,
        )
        self.session.add(item)
        self.session.flush()
        item = model.Category(name='Fedora Archive',
                              product_id=1,
                              canonicalhost='http://archive.fedoraproject.org',
                              topdir_id=10,
                              publiclist=True)
        self.session.add(item)

        item = model.CategoryDirectory(
            directory_id=6,
            category_id=1,
        )
        self.session.add(item)
        item = model.CategoryDirectory(
            directory_id=8,
            category_id=1,
        )
        self.session.add(item)

        self.session.commit()

        # Before the script

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 4)
        self.assertEqual(results[0].prefix, 'updates-testing-f25')
        self.assertEqual(results[0].directory.name,
                         'pub/fedora/linux/updates/testing/25/x86_64')
        self.assertEqual(results[1].prefix, 'updates-testing-f26')
        self.assertEqual(results[1].directory.name,
                         'pub/fedora/linux/updates/testing/26/x86_64')
        self.assertEqual(results[2].prefix, 'updates-testing-f27')
        self.assertEqual(results[2].directory.name,
                         'pub/fedora/linux/updates/testing/27/x86_64')

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 1 more here, 9+1=10
        self.assertEqual(len(results), 10)
        self.assertEqual(results[0].name, 'pub/fedora/linux')
        self.assertEqual(results[1].name, 'pub/fedora/linux/extras')
        self.assertEqual(results[2].name, 'pub/epel')
        self.assertEqual(results[3].name, 'pub/fedora/linux/releases/26')
        self.assertEqual(results[4].name, 'pub/fedora/linux/releases/27')
        self.assertEqual(
            results[5].name,
            'pub/archive/fedora/linux/releases/26/Everything/source')
        self.assertEqual(results[6].name,
                         'pub/fedora/linux/updates/testing/25/x86_64')
        self.assertEqual(results[7].name,
                         'pub/fedora/linux/updates/testing/26/x86_64')
        self.assertEqual(results[8].name,
                         'pub/fedora/linux/updates/testing/27/x86_64')
        self.assertEqual(results[9].name, 'pub/archive')

        process = subprocess.Popen(args=command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout, 'trying to find pub/archive/fedora/linux/updates/testing/'
            '26/x86_64\n'
            'Unable to find a directory in [Fedora Archive] for pub/fedora/'
            'linux/updates/testing/26/x86_64\n')
        self.assertEqual(stderr, '')

        # Run the script so that it works

        item = model.Directory(
            name='pub/archive/fedora/linux/updates/testing/26/x86_64',
            readable=True,
        )
        self.session.add(item)
        self.session.commit()

        process = subprocess.Popen(args=command,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   universal_newlines=True)
        stdout, stderr = process.communicate()

        self.assertEqual(
            stdout, 'trying to find pub/archive/fedora/'
            'linux/updates/testing/26/x86_64\n'
            'pub/fedora/linux/updates/testing/26/x86_64 => '
            'pub/archive/fedora/linux/updates/testing/26/x86_64\n')
        self.assertEqual(stderr, '')

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 4)
        self.assertEqual(results[0].prefix, 'updates-testing-f25')
        self.assertEqual(results[0].directory.name,
                         'pub/fedora/linux/updates/testing/25/x86_64')
        self.assertEqual(results[1].prefix, 'updates-testing-f26')
        self.assertEqual(results[1].directory.name,
                         'pub/archive/fedora/linux/updates/testing/26/x86_64')
        self.assertEqual(results[2].prefix, 'updates-testing-f27')
        self.assertEqual(results[2].directory.name,
                         'pub/fedora/linux/updates/testing/27/x86_64')

        # After the script

        results = mirrormanager2.lib.get_directories(self.session)
        # create_directory creates 9 directories
        # we create 1 more here, 9+1=10
        self.assertEqual(len(results), 11)
        self.assertEqual(results[0].name, 'pub/fedora/linux')
        self.assertEqual(results[1].name, 'pub/fedora/linux/extras')
        self.assertEqual(results[2].name, 'pub/epel')
        self.assertEqual(results[3].name, 'pub/fedora/linux/releases/26')
        self.assertEqual(results[4].name, 'pub/fedora/linux/releases/27')
        self.assertEqual(
            results[5].name,
            'pub/archive/fedora/linux/releases/26/Everything/source')
        self.assertEqual(results[6].name,
                         'pub/fedora/linux/updates/testing/25/x86_64')
        self.assertEqual(results[7].name,
                         'pub/fedora/linux/updates/testing/26/x86_64')
        self.assertEqual(results[8].name,
                         'pub/fedora/linux/updates/testing/27/x86_64')
        self.assertEqual(results[9].name, 'pub/archive')
        self.assertEqual(results[10].name,
                         'pub/archive/fedora/linux/updates/testing/26/x86_64')
コード例 #47
0
    def test_1_umdl(self):
        """ Test the umdl cron. """

        # Fill the DB a little bit
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_categorydirectory(self.session)

        # Run the UDML

        process = subprocess.Popen(args=self.umdl_command.split(),
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        self.assertEqual(stdout, '')
        self.assertEqual(stderr, '')

        with open(self.logfile) as stream:
            logs = stream.readlines()
        self.assertEqual(len(logs), 3)
        logs = ''.join([
            log.split(' ', 3)[-1]
            for log in logs
        ])
        exp ="""umdl_master_directories Category Fedora Secondary Arches does not exist in the database, skipping
umdl_master_directories Category Fedora Archive does not exist in the database, skipping
umdl_master_directories Category Fedora Other does not exist in the database, skipping
"""
        self.assertEqual(logs, exp)

        # The DB should now be filled with what UMDL added, so let's check it
        results = mirrormanager2.lib.query_directories(self.session)
        self.assertEqual(len(results), 0)

        results = mirrormanager2.lib.get_versions(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'development')
        self.assertEqual(results[0].product.name, 'Fedora')
        self.assertEqual(results[1].name, '21')
        self.assertEqual(results[1].product.name, 'Fedora')

        results = mirrormanager2.lib.get_categories(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'Fedora Linux')
        self.assertEqual(results[1].name, 'Fedora EPEL')

        results = mirrormanager2.lib.get_products(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(results[0].name, 'EPEL')
        self.assertEqual(results[1].name, 'Fedora')

        results = mirrormanager2.lib.get_repositories(self.session)
        self.assertEqual(len(results), 2)
        self.assertEqual(
            results[0].name, 'pub/fedora/linux/releases/atomic/rawhide')
        self.assertEqual(results[0].category.name, 'Fedora Linux')
        self.assertEqual(results[0].version.name, 'development')
        self.assertEqual(results[0].arch.name, 'x86_64')
        self.assertEqual(
            results[0].directory.name,
            'pub/fedora/linux/releases/atomic/rawhide')
        self.assertEqual(results[0].prefix, 'atomic-unknown')

        self.assertEqual(
            results[1].name, 'pub/fedora/linux/releases/atomic/21')
        self.assertEqual(results[1].category.name, 'Fedora Linux')
        self.assertEqual(results[1].version.name, '21')
        self.assertEqual(results[1].arch.name, 'x86_64')
        self.assertEqual(
            results[1].directory.name, 'pub/fedora/linux/releases/atomic/21')
        self.assertEqual(results[1].prefix, 'atomic-21')

        results = mirrormanager2.lib.get_arches(self.session)
        self.assertEqual(len(results), 4)
        self.assertEqual(results[0].name, 'i386')
        self.assertEqual(results[1].name, 'ppc')
        self.assertEqual(results[2].name, 'source')
        self.assertEqual(results[3].name, 'x86_64')

        results = mirrormanager2.lib.get_directories(self.session)
        # tree testdata/pub says there are 84 directories and 150 files
        # There are 7 directories added by create_directory which are not
        # present on the FS, 84 + 7 = 91, so we are good \ó/
        self.assertEqual(len(results), 91)
        self.assertEqual(results[0].name, 'pub/fedora/linux/releases')
        self.assertEqual(results[1].name, 'pub/fedora/linux/extras')
        self.assertEqual(results[2].name, 'pub/epel')
        self.assertEqual(results[3].name, 'pub/fedora/linux/releases/20')
        self.assertEqual(results[4].name, 'pub/fedora/linux/releases/21')
        self.assertEqual(
            results[5].name,
            'pub/archive/fedora/linux/releases/20/Fedora/source')
        self.assertEqual(
            results[20].name,
            'pub/fedora/linux/releases/atomic/21/refs/heads/fedora-atomic/f21')
        self.assertEqual(
            results[21].name,
            'pub/fedora/linux/releases/atomic/21/refs/heads/'
            'fedora-atomic/f21/x86_64')
        self.assertEqual(
            results[22].name,
            'pub/fedora/linux/releases/atomic/21/refs/heads/'
            'fedora-atomic/f21/x86_64/updates')
        self.assertEqual(
            results[23].name,
            'pub/fedora/linux/releases/atomic/21/refs/remotes')
        self.assertEqual(
            results[24].name,
            'pub/fedora/linux/releases/atomic/21/remote-cache')

        results = mirrormanager2.lib.get_file_detail(
            self.session, 'repomd.xml', 7)
        self.assertEqual(results, None)

        results = mirrormanager2.lib.get_file_details(self.session)
        self.assertEqual(len(results), 9)

        cnt = 0
        self.assertEqual(results[cnt].filename, 'Fedora-20-x86_64-DVD.iso')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Fedora/x86_64/iso')
        self.assertEqual(results[cnt].sha512, None)
        self.assertEqual(
            results[cnt].sha256,
            'f2eeed5102b8890e9e6f4b9053717fe73031e699c4b76dc7028749ab66e7f917')

        cnt = 1
        self.assertEqual(results[cnt].filename, 'Fedora-20-x86_64-netinst.iso')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Fedora/x86_64/iso')
        self.assertEqual(results[cnt].sha512, None)
        self.assertEqual(
            results[cnt].sha256,
            '376be7d4855ad6281cb139430606a782fd6189dcb01d7b61448e915802cc350f')

        cnt = 2
        self.assertEqual(
            results[cnt].filename, 'Fedora-Live-Desktop-x86_64-20-1.iso')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Live/x86_64')
        self.assertEqual(results[cnt].sha512, None)
        self.assertEqual(
            results[cnt].sha256,
            'cc0333be93c7ff2fb3148cb29360d2453f78913cc8aa6c6289ae6823372a77d2')

        cnt = 3
        self.assertEqual(
            results[cnt].filename, 'Fedora-Live-KDE-x86_64-20-1.iso')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Live/x86_64')
        self.assertEqual(results[cnt].sha512, None)
        self.assertEqual(
            results[cnt].sha256,
            '08360a253b4a40dff948e568dba1d2ae9d931797f57aa08576b8b9f1ef7e4745')

        cnt = 4
        self.assertEqual(results[cnt].filename, 'repomd.xml')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/development/22/x86_64/os/repodata')
        self.assertEqual(
            results[cnt].sha256,
            '108b4102829c0839c7712832577fe7da24f0a9491f4dc25d4145efe6aced2ebf')
        self.assertEqual(
            results[cnt].sha512,
            '50ed8cb8f4daf8bcd1d0ccee1710b8a87ee8de5861fb15a1023d6558328795'
            'f42dade3e025c09c20ade36c77a3a82d9cdce1a2e2ad171f9974bc1889b591'
            '8020')

        cnt = 5
        self.assertEqual(results[cnt].filename, 'summary')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/atomic/rawhide')
        self.assertEqual(
            results[cnt].sha256,
            '6b439b70ecb1941e0e2e0ea0817a66715067cbd96d4367f4cd23ca287aeb14cb')
        self.assertEqual(
            results[cnt].sha512,
            '6f3cafa7f16b796a6051f740de17344542feb8b2285e3ccd9b141217fbb5f0'
            'b602c2389e4a40fe3b1aeac6f853b4c6d2d6c863e3649f567bd1af2aea502f'
            'd9e8')

        cnt = 6
        self.assertEqual(results[cnt].filename, 'summary')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/atomic/21')
        self.assertEqual(
            results[cnt].sha256,
            '6b439b70ecb1941e0e2e0ea0817a66715067cbd96d4367f4cd23ca287aeb14cb')
        self.assertEqual(
            results[cnt].sha512,
            '6f3cafa7f16b796a6051f740de17344542feb8b2285e3ccd9b141217fbb5f0'
            'b602c2389e4a40fe3b1aeac6f853b4c6d2d6c863e3649f567bd1af2aea502f'
            'd9e8')

        cnt = 7
        self.assertEqual(results[cnt].filename, 'repomd.xml')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Fedora/source/SRPMS/repodata')
        self.assertEqual(
            results[cnt].sha256,
            '9a4738934092cf17e4540ee9cab741e922eb8306875ae5621feb01ebeb1f67f2')
        self.assertEqual(
            results[cnt].sha512,
            '3351c7a6b1d2bd94e375d09324a9280b8becfe4dea40a227c3b270ddcedb19'
            'f420eec3f2c6a39a1edcdf52f80d31eb47a0ba25057ced2e3182dd212bc746'
            '6ba2')

        cnt = 8
        self.assertEqual(results[cnt].filename, 'repomd.xml')
        self.assertEqual(
            results[cnt].directory.name,
            'pub/fedora/linux/releases/releases/20/Fedora/x86_64/os/repodata')
        self.assertEqual(
            results[cnt].sha256,
            '108b4102829c0839c7712832577fe7da24f0a9491f4dc25d4145efe6aced2ebf')
        self.assertEqual(
            results[cnt].sha512,
            '50ed8cb8f4daf8bcd1d0ccee1710b8a87ee8de5861fb15a1023d6558328795'
            'f42dade3e025c09c20ade36c77a3a82d9cdce1a2e2ad171f9974bc1889b591'
            '8020')

        results = mirrormanager2.lib.get_host_category_dirs(self.session)
        self.assertEqual(len(results), 0)