import pytest from dmp.shopify.models import ( ShopifyCollection, ShopifyCollectionArtist, ShopifyStoreAssociation, ) from dmp.shopify.repositories import CollectionArtistRepository, CollectionRepository from tests.unit.types import CreateReportingModel, CreateReportingModelBatch class TestCollectionArtistRepository: @pytest.mark.db def test_delete_by_association_id( self, repository: CollectionArtistRepository, collection_repository: CollectionRepository, create_reporting_model: CreateReportingModel, create_reporting_model_batch: CreateReportingModelBatch, ) -> None: association = create_reporting_model( ShopifyStoreAssociation, global_participant_id=None ) collections = create_reporting_model_batch( ShopifyCollection, size=2, source_schema=association.fivetran_schema ) create_reporting_model( ShopifyCollectionArtist, association_id=association.id, collection_id=collections[0].id, ) create_reporting_model( ShopifyCollectionArtist, association_id=association.id, collection_id=collections[1].id, ) repository.delete_by_association_id(association_id=association.id) updated_collections = collection_repository.find_by_association_id( association_id=association.id ) assert updated_collections[0].global_participant_id is None assert updated_collections[1].global_participant_id is None