def test_synchronisation_no_checksums_in_db( repo_content, mirror_channel, dao, config, dummy_response, db, user, n_new_packages, arch, package_version, mocker, ): package_info = '{"size": 5000, "subdirs":["noarch"]}' package_version.info = package_info db.commit() pkgstore = config.get_package_store() rules = Rules("", {"user_id": str(uuid.UUID(bytes=user.id))}, db) class DummySession: def get(self, path, stream=False): return dummy_response() def close(self): pass # generate local repodata.json update_indexes(dao, pkgstore, mirror_channel.name) dummy_repo = RemoteRepository("", DummySession()) initial_sync_mirror( mirror_channel.name, dummy_repo, arch, dao, pkgstore, rules, skip_errors=False, ) versions = ( db.query(PackageVersion) .filter(PackageVersion.channel_name == mirror_channel.name) .all() ) assert len(versions) == n_new_packages + 1
def test_synchronisation_timestamp( mirror_channel, dao, config, dummy_response, db, user, expected_timestamp, timestamp_mirror_sync, new_package, ): mirror_channel.timestamp_mirror_sync = timestamp_mirror_sync pkgstore = config.get_package_store() rules = Rules("", {"user_id": str(uuid.UUID(bytes=user.id))}, db) class DummySession: def get(self, path, stream=False): return dummy_response() dummy_repo = RemoteRepository("", DummySession()) initial_sync_mirror( mirror_channel.name, dummy_repo, "linux-64", dao, pkgstore, rules, skip_errors=False, ) channel = db.query(Channel).get(mirror_channel.name) assert channel.timestamp_mirror_sync == expected_timestamp if new_package: assert channel.packages[0].name == "test-package" db.delete(channel.packages[0]) db.commit() else: assert not channel.packages
def test_synchronisation_sha( repo_content, mirror_channel, dao, config, dummy_response, db, user, n_new_packages, arch, package_version, ): pkgstore = config.get_package_store() rules = Rules("", {"user_id": str(uuid.UUID(bytes=user.id))}, db) class DummySession: def get(self, path, stream=False): return dummy_response() # generate local repodata.json update_indexes(dao, pkgstore, mirror_channel.name) dummy_repo = RemoteRepository("", DummySession()) initial_sync_mirror( mirror_channel.name, dummy_repo, arch, dao, pkgstore, rules, skip_errors=False, ) versions = (db.query(PackageVersion).filter( PackageVersion.channel_name == mirror_channel.name).all()) assert len(versions) == n_new_packages + 1