# pylint: disable=unused-argument,protected-access,too-many-arguments import pytest from db_schema.schemas import slz @pytest.mark.integration def test_get_latest_hash_return_none(snapshot_repository, content_status, clean_db): assert not snapshot_repository._get_last_snapshot_hash(content_status) @pytest.mark.integration def test_get_latest_hash_return_hash(snapshot_repository, snapshot, clean_db, content_status): assert snapshot_repository._get_last_snapshot_hash(content_status) == snapshot.hash @pytest.mark.integration @pytest.mark.parametrize( 'latest_hash, is_hash_updated', [ (None, True), ('latest_hash', True), ('7c00ff0338fcbc78d6a4487fda47c608', False), ] ) def test_is_hash_updated( snapshot_repository, content_status, latest_hash, is_hash_updated, snapshot, clean_db ): assert snapshot_repository.is_hash_updated(latest_hash, content_status) == is_hash_updated @pytest.mark.integration def test_persist_snapshot(db, snapshot_repository, content_status, clean_db): file_name = 'charts_daily_regional_20210801_us.parquet' response_hash = '7c00ff0338fcbc78d6a4487fda47c608' assert not db.query(slz.Snapshot).filter( slz.Snapshot.file_name == file_name, slz.Snapshot.hash == response_hash, ).one_or_none() snapshot_repository.persist_snapshot(file_name, response_hash, content_status) assert db.query(slz.Snapshot).filter( slz.Snapshot.file_name == file_name, slz.Snapshot.hash == response_hash, slz.Snapshot.content_status == content_status ).one()