def test_list_packages_remote_repo_cached(self): t = DummyHTTPServerThread(53135, self.tmpdir) try: t.start() time.sleep(1) rpm_metadata = RpmMetadata("test_repo_http", ["http://localhost:53135/"]) rpm_metadata.cachedir = self.cachedir pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result(pkgs, "http://localhost:53135/{0}".format( os.path.basename(self.rpm))) pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result(pkgs, "http://localhost:53135/{0}".format( os.path.basename(self.rpm))) pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result(pkgs, "http://localhost:53135/{0}".format( os.path.basename(self.rpm))) finally: t.stop_it() t.join(2) if t.isAlive(): os.abort() handled_requests = t.rqueue.get() self.assertEqual(handled_requests, 2)
def test_list_packages_file_repo(self): """ Test whether list_packages lists our ad-hoc repository with file:// protocol in URL correctly. """ rpm_metadata = RpmMetadata("test_repo_file", ["file://" + self.tmpdir]) rpm_metadata.cachedir = self.cachedir pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result( pkgs, "file://{0}".format( os.path.join(self.tmpdir, os.path.basename(self.rpm))))
def test_list_packages_file_repo(self): """ Test whether list_packages lists our ad-hoc repository with file:// protocol in URL correctly. """ rpm_metadata = RpmMetadata("test_repo_file", ["file://" + self.tmpdir]) rpm_metadata.cachedir = self.cachedir pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result(pkgs, "file://{0}".format(os.path.join(self.tmpdir, os.path.basename(self.rpm))))
def test_list_packages_remote_repo_NO_cache(self): t = DummyHTTPServerThread(53535, self.tmpdir) try: t.start() time.sleep(1) rpm_metadata = RpmMetadata("test_repo_http", ["http://localhost:53535/"]) rpm_metadata.cachedir = self.cachedir rpm_metadata.cacheperiod = -1 pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result( pkgs, "http://localhost:53535/{0}".format( os.path.basename(self.rpm))) pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result( pkgs, "http://localhost:53535/{0}".format( os.path.basename(self.rpm))) pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result( pkgs, "http://localhost:53535/{0}".format( os.path.basename(self.rpm))) finally: t.stop_it() t.join(2) if t.isAlive(): os.abort() handled_requests = t.rqueue.get() self.assertEqual(handled_requests, 6)
def test_list_packages_remote_repo_NO_cache(self): with DummyHTTPServer(53535, self.tmpdir) as httpd: httpd.serve_forever() rpm_metadata = RpmMetadata("test_repo_http", ["http://localhost:53535/"]) rpm_metadata.cachedir = self.cachedir rpm_metadata.cacheperiod = -1 pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result( pkgs, "http://localhost:53535/{0}".format( os.path.basename(self.rpm))) pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result( pkgs, "http://localhost:53535/{0}".format( os.path.basename(self.rpm))) pkgs = rpm_metadata.list_packages(["noarch"]) self.verify_result( pkgs, "http://localhost:53535/{0}".format( os.path.basename(self.rpm))) httpd.shutdown() self.assertEqual(httpd.requests, 6)