Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 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)
    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)
Esempio n. 5
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/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')
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
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, [])
Esempio n. 9
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, [])
    def test_hostcategory_repr(self):
        """ Test the HostCategory.__repr__ object of mirrormanager2.lib.model.
        """
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_hostcategory(self.session)

        item = model.HostCategory.get(self.session, 1)
        self.assertEqual(
            str(item), '<HostCategory(1 - <Category(1 - Fedora Linux)>)>')
        item = model.HostCategory.get(self.session, 2)
        self.assertEqual(
            str(item), '<HostCategory(2 - <Category(2 - Fedora EPEL)>)>')
Esempio n. 11
0
    def test_hostcategory_repr(self):
        """ Test the HostCategory.__repr__ object of mirrormanager2.lib.model.
        """
        tests.create_base_items(self.session)
        tests.create_directory(self.session)
        tests.create_category(self.session)
        tests.create_site(self.session)
        tests.create_hosts(self.session)
        tests.create_hostcategory(self.session)

        item = model.HostCategory.get(self.session, 1)
        self.assertEqual(
            str(item), '<HostCategory(1 - <Category(1 - Fedora Linux)>)>')
        item = model.HostCategory.get(self.session, 2)
        self.assertEqual(
            str(item), '<HostCategory(2 - <Category(2 - Fedora EPEL)>)>')
Esempio n. 12
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)
Esempio n. 13
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)
Esempio n. 14
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')
Esempio n. 15
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')
Esempio n. 16
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')
Esempio n. 17
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)
    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)
Esempio n. 19
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')
Esempio n. 20
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')