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)
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 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')
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)
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_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)
def test_get_directory_exclusive_host(self): """ Test the get_directory_exclusive_host function of mirrormanager2.lib. """ results = mirrormanager2.lib.get_directory_exclusive_host( 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_directoryexclusivehost(self.session) results = mirrormanager2.lib.get_directory_exclusive_host( self.session) self.assertEqual(len(results), 2) self.assertEqual( results[0].dname, 'pub/fedora/linux/releases/20') self.assertEqual( results[0].host_id, 1) self.assertEqual( results[1].dname, 'pub/fedora/linux/releases/21') self.assertEqual( results[1].host_id, 3)
def test_host_repr(self): """ Test the Host.__repr__ object of mirrormanager2.lib.model. """ tests.create_site(self.session) tests.create_hosts(self.session) item = model.Host.get(self.session, 1) self.assertEqual(str(item), '<Host(1 - mirror.localhost)>') item = model.Host.get(self.session, 3) self.assertEqual(str(item), '<Host(3 - private.localhost)>')
def test_host_json(self): """ Test the Host.__json__ object of mirrormanager2.lib.model. """ tests.create_site(self.session) tests.create_hosts(self.session) item = model.Host.get(self.session, 1) self.assertEqual( item.__json__(), { 'admin_active': True, 'asn': None, 'asn_clients': False, 'bandwidth_int': 100, 'comment': None, 'country': u'US', 'id': 1, 'internet2': False, 'internet2_clients': False, 'last_checked_in': None, 'last_crawl_duration': 0, 'last_crawled': None, 'max_connections': 10, 'name': u'mirror.localhost', 'private': False, 'site': { 'id': 1, 'name': u'test-mirror' }, 'user_active': True }) item = model.Host.get(self.session, 3) self.assertEqual( item.__json__(), { 'admin_active': True, 'asn': None, 'asn_clients': False, 'bandwidth_int': 100, 'comment': 'My own private mirror', 'country': u'NL', 'id': 3, 'internet2': False, 'internet2_clients': False, 'last_checked_in': None, 'last_crawl_duration': 0, 'last_crawled': None, 'max_connections': 10, 'name': u'private.localhost', 'private': True, 'site': { 'id': 1, 'name': u'test-mirror' }, 'user_active': True })
def test_host_json(self): """ Test the Host.__json__ object of mirrormanager2.lib.model. """ tests.create_site(self.session) tests.create_hosts(self.session) item = model.Host.get(self.session, 1) self.assertEqual( item.__json__(), { 'admin_active': True, 'asn': None, 'asn_clients': False, 'bandwidth_int': 100, 'comment': None, 'country': u'US', 'id': 1, 'internet2': False, 'internet2_clients': False, 'last_checked_in': None, 'last_crawl_duration': 0, 'last_crawled': None, 'max_connections': 10, 'name': u'mirror.localhost', 'private': False, 'site': {'id': 1, 'name': u'test-mirror'}, 'user_active': True } ) item = model.Host.get(self.session, 3) self.assertEqual( item.__json__(), { 'admin_active': True, 'asn': None, 'asn_clients': False, 'bandwidth_int': 100, 'comment': 'My own private mirror', 'country': u'NL', 'id': 3, 'internet2': False, 'internet2_clients': False, 'last_checked_in': None, 'last_crawl_duration': 0, 'last_crawled': None, 'max_connections': 10, 'name': u'private.localhost', 'private': True, 'site': {'id': 1, 'name': u'test-mirror'}, 'user_active': True } )
def test_get_host_peer_asn(self): """ Test the get_host_peer_asn function of mirrormanager2.lib. """ results = mirrormanager2.lib.get_host_peer_asn(self.session, 1) self.assertEqual(results, None) tests.create_site(self.session) tests.create_hosts(self.session) tests.create_hostpeerasn(self.session) results = mirrormanager2.lib.get_host_peer_asn(self.session, 1) self.assertEqual(results.host.name, 'private.localhost') self.assertEqual(results.host.country, 'NL') results = mirrormanager2.lib.get_host_peer_asn(self.session, 2) self.assertEqual(results, None)
def test_host_is_active(self): """ Test the Host.is_active object of mirrormanager2.lib.model. """ tests.create_site(self.session) tests.create_hosts(self.session) item = model.Host.get(self.session, 1) self.assertTrue(item.is_active()) item.admin_active = False self.session.add(item) self.session.commit() item = model.Host.get(self.session, 1) self.assertFalse(item.is_active())
def test_get_host_acl_ip(self): """ Test the get_host_acl_ip function of mirrormanager2.lib. """ results = mirrormanager2.lib.get_host_acl_ip(self.session, 1) self.assertEqual(results, None) tests.create_site(self.session) tests.create_hosts(self.session) tests.create_hostaclip(self.session) results = mirrormanager2.lib.get_host_acl_ip(self.session, 1) self.assertEqual(results.host.name, 'mirror.localhost') self.assertEqual(results.host.country, 'US') results = mirrormanager2.lib.get_host_acl_ip(self.session, 2) self.assertEqual(results.host.name, 'mirror2.localhost') self.assertEqual(results.host.country, 'FR')
def test_get_hosts(self): """ Test the get_hosts function of mirrormanager2.lib. """ results = mirrormanager2.lib.get_hosts(self.session) self.assertEqual(results, []) tests.create_site(self.session) tests.create_hosts(self.session) results = mirrormanager2.lib.get_hosts(self.session) self.assertEqual(len(results), 3) self.assertEqual(results[0].name, 'mirror.localhost') self.assertEqual(results[0].country, 'US') self.assertEqual(results[1].name, 'mirror2.localhost') self.assertEqual(results[1].country, 'FR') self.assertEqual(results[2].name, 'private.localhost') self.assertEqual(results[2].country, 'NL')
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)>)>')
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)
def test_get_directory_exclusive_host(self): """ Test the get_directory_exclusive_host function of mirrormanager2.lib. """ results = mirrormanager2.lib.get_directory_exclusive_host(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_directoryexclusivehost(self.session) results = mirrormanager2.lib.get_directory_exclusive_host(self.session) self.assertEqual(len(results), 2) self.assertEqual(results[0].dname, 'pub/fedora/linux/releases/20') self.assertEqual(results[0].host_id, 1) self.assertEqual(results[1].dname, 'pub/fedora/linux/releases/21') self.assertEqual(results[1].host_id, 3)
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')
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')
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_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')
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')
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')