from unittest import mock import pytest from dmp.adapters.fivetran.models import ConnectCard from dmp.shopify.handlers import ReconnectStoreHandler, ReconnectStoreRequest from dmp.shopify.models import ShopifyStoreAssociation from tests.unit.faker import FakerTyped from tests.unit.types import BuildModel, CreateReportingModel class TestReconnectStoreHandler: @pytest.mark.db def test_reconnect_store( self, handler: ReconnectStoreHandler, fake: FakerTyped, build_model: BuildModel, create_reporting_model: CreateReportingModel, fivetran_client_mock: mock.MagicMock, ) -> None: store = create_reporting_model(ShopifyStoreAssociation) fivetran_client_mock.get_connect_card = mock.Mock( return_value=build_model(ConnectCard) ) association, connect_card = handler.handle( ReconnectStoreRequest( identity_id=fake.uuid4_string(), association_id=store.id, redirect_uri=fake.url(), ) ) assert association.id == store.id