# pylint: disable=unused-argument,protected-access import pytest from db_schema.schemas import slz @pytest.mark.integration def test__get_latest_hash_return_none(snapshot_repository): assert not snapshot_repository._get_latest_hash() @pytest.mark.integration def test__get_latest_hash_return_hash(snapshot_repository, snapshot, clean_db): latest_hash = snapshot.hash assert snapshot_repository._get_latest_hash() == latest_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, latest_hash, is_hash_updated, snapshot, clean_db): assert snapshot_repository.is_hash_updated(latest_hash) == is_hash_updated @pytest.mark.integration def test_persist_snapshot(db, snapshot_repository, content_status, clean_db): file_name = '26640_1618316450.csv' 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()