def test_sync(self, tmp_path): path = tmp_path / 'repo' syncer = tar_syncer( str(path), "https://github.com/pkgcore/pkgrepo/archive/master.tar.gz") assert syncer.sync() layout_conf = os.path.join(path, 'metadata', 'layout.conf') assert os.path.exists(layout_conf) stat = os.stat(layout_conf) # re-sync and verify that the repo didn't get replaced assert syncer.sync() assert stat == os.stat(layout_conf) # forcibly re-sync and verify that the repo gets replaced assert syncer.sync(force=True) assert stat != os.stat(layout_conf)
def test_uri_parse(self): assert tar_syncer.parse_uri("tar+http://repo.tar.gz") == "http://repo.tar.gz" # missing actual URI protocol with pytest.raises(base.UriError): tar_syncer.parse_uri("tar+://repo.tar.gz") # invalid compression suffix with pytest.raises(base.UriError): tar_syncer.parse_uri("tar+https://repo.tar.foo") for ext in tar_syncer.supported_exts: for proto in ('http', 'https'): for uri in (f"tar+{proto}://repo{ext}", f"{proto}://repo{ext}"): o = tar_syncer("/tmp/foon", uri) assert o.uri == f"{proto}://repo{ext}"
def test_sync(self, tmp_path): # perform a tarball sync for initial week-old base path = tmp_path / 'repo' week_old = datetime.datetime.now() - datetime.timedelta(days=7) date_str = week_old.strftime("%Y%m%d") syncer = tar_syncer( str(path), f"http://distfiles.gentoo.org/snapshots/portage-{date_str}.tar.xz") assert syncer.sync() timestamp = os.path.join(path, 'metadata', 'timestamp.chk') assert os.path.exists(timestamp) stat = os.stat(timestamp) # run rsync over the unpacked repo tarball to update to the latest tree syncer = rsync.rsync_timestamp_syncer( str(path), "rsync://rsync.gentoo.org/gentoo-portage") assert syncer.sync() assert stat != os.stat(timestamp)