# pylint: disable=too-many-statements import json import pytest from dapd_db_schema.schemas.etl import DimArtist, FactArtistFollowers from dapd_transformation_service.entities.dimension_meta import DspEnum from dapd_transformation_service.services.facts.fact_artist_followers import ( FactArtistFollowersService, ) pytestmark = pytest.mark.integration # noinspection PyTestParametrized @pytest.mark.parametrize(['dsp', 'dim_type'], [[DspEnum.SPOTIFY, DimArtist]]) def test_process_artist_followers(db, dim_artist, raw_data): assert db.query(FactArtistFollowers).count() == 0 data = json.loads(raw_data) service = FactArtistFollowersService(db) service.process_dimension(dim_artist, data) assert db.query(FactArtistFollowers).count() == 1 fact = db.query(FactArtistFollowers).filter( FactArtistFollowers.artist_id == data['item']['id'] ).one() assert fact.followers == data['item']['followers']['total']