import pytest from apollo_messages_views.constants.base import EventView from tests.data.messages import push_messages as pm @pytest.mark.parametrize( "input_messages,expected_result_len,expected_result", ( ( [ pm.feed_update_message(1, 1, 2, country_code="fr", exclude=("data.recipient.devices",)), pm.feed_update_message(2, 6, 2, country_code="ay", exclude={"ttl": 5}), pm.feed_top_entry_message(3, 1, 1, exclude=("data.content.track.artists",)), pm.feed_starred_entry_message(4, 5, 2, exclude=("data.content.track",)), pm.feed_top_exit_message(3, 1, 1, exclude=("data.content.track.artists",)), pm.feed_starred_exit_message(4, 5, 2, exclude=("data.content.track",)), pm.feed_top_major_move_message(3, 1, 1, exclude=("data.content.track.artists",)), pm.feed_starred_major_move_message(4, 5, 2, exclude=("data.content.track",)), pm.feed_chart_update_message(1, 1, 2, country_code="fr", exclude=("data.recipient.devices",)), pm.feed_chart_update_message(2, 6, 2, country_code="ay", exclude={"ttl": 5}), ], 0, None ), ( [ pm.feed_update_message(1, 1, country_code="gb", dsp="apple", account_id=4), pm.feed_update_message(2, 2, country_code="global", dsp="spotify", account_id=9), pm.feed_starred_entry_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.feed_starred_entry_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.feed_top_entry_message(5, 5, 3, country_code="fr", dsp="apple", account_id=2), pm.feed_top_entry_message(6, 2, 8, country_code="au", dsp="spotify", account_id=1), pm.feed_starred_exit_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.feed_starred_exit_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.feed_top_exit_message(5, 5, 3, country_code="fr", dsp="apple", account_id=2), pm.feed_top_exit_message(6, 2, 8, country_code="au", dsp="spotify", account_id=1), pm.feed_starred_major_move_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.feed_starred_major_move_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.feed_top_major_move_message(5, 5, 3, country_code="fr", dsp="apple", account_id=2), pm.feed_top_major_move_message(6, 2, 8, country_code="au", dsp="spotify", account_id=1), pm.feed_starred_major_move_message( 3, 1, 3, country_code="us", dsp="apple", account_id=1, move_up=False ), pm.feed_starred_major_move_message( 4, 2, 4, country_code="us", dsp="spotify", account_id=1, move_up=False ), pm.feed_top_major_move_message( 5, 5, 3, country_code="fr", dsp="apple", account_id=2, move_up=False ), pm.feed_top_major_move_message( 6, 2, 8, country_code="au", dsp="spotify", account_id=1, move_up=False ) ], 18, [ pm.parsed_feed_update_message(1, 1, country_code="gb", dsp="apple", account_id=4), pm.parsed_feed_update_message(2, 2, country_code="global", dsp="spotify", account_id=9), pm.parsed_feed_starred_entry_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.parsed_feed_starred_entry_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.parsed_feed_top_entry_message(5, 5, 3, country_code="fr", dsp="apple", account_id=2), pm.parsed_feed_top_entry_message(6, 2, 8, country_code="au", dsp="spotify", account_id=1), pm.parsed_feed_starred_exit_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.parsed_feed_starred_exit_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.parsed_feed_top_exit_message(5, 5, 3, country_code="fr", dsp="apple", account_id=2), pm.parsed_feed_top_exit_message(6, 2, 8, country_code="au", dsp="spotify", account_id=1), pm.parsed_feed_starred_major_move_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.parsed_feed_starred_major_move_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.parsed_feed_top_major_move_message(5, 5, 3, country_code="fr", dsp="apple", account_id=2), pm.parsed_feed_top_major_move_message(6, 2, 8, country_code="au", dsp="spotify", account_id=1), pm.parsed_feed_starred_major_move_message( 3, 1, 3, country_code="us", dsp="apple", account_id=1, move_up=False ), pm.parsed_feed_starred_major_move_message( 4, 2, 4, country_code="us", dsp="spotify", account_id=1, move_up=False ), pm.parsed_feed_top_major_move_message( 5, 5, 3, country_code="fr", dsp="apple", account_id=2, move_up=False ), pm.parsed_feed_top_major_move_message( 6, 2, 8, country_code="au", dsp="spotify", account_id=1, move_up=False ) ] ), ( [ pm.feed_chart_update_message(1, 1, country_code="gb", dsp="apple", account_id=4), pm.feed_chart_update_message(2, 2, country_code="global", dsp="spotify", account_id=9), pm.feed_top_chart_entry_message(5, 5, 3, country_code="fr", dsp="apple", account_id=2), pm.feed_top_chart_entry_message(6, 2, 8, country_code="au", dsp="spotify", account_id=1), pm.feed_top_chart_exit_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.feed_top_chart_exit_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.feed_top_chart_major_move_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.feed_top_chart_major_move_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.feed_top_chart_major_move_message( 3, 1, 3, country_code="us", dsp="apple", account_id=1, move_up=False ), pm.feed_top_chart_major_move_message( 4, 2, 4, country_code="us", dsp="spotify", account_id=1, move_up=False ), ], 10, [ pm.parsed_feed_chart_update_message(1, 1, country_code="gb", dsp="apple", account_id=4), pm.parsed_feed_chart_update_message(2, 2, country_code="global", dsp="spotify", account_id=9), pm.parsed_feed_top_chart_entry_message(5, 5, 3, country_code="fr", dsp="apple", account_id=2), pm.parsed_feed_top_chart_entry_message(6, 2, 8, country_code="au", dsp="spotify", account_id=1), pm.parsed_feed_top_chart_exit_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.parsed_feed_top_chart_exit_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.parsed_feed_top_chart_major_move_message(3, 1, 3, country_code="us", dsp="apple", account_id=1), pm.parsed_feed_top_chart_major_move_message(4, 2, 4, country_code="us", dsp="spotify", account_id=1), pm.parsed_feed_top_chart_major_move_message( 3, 1, 3, country_code="us", dsp="apple", account_id=1, move_up=False ), pm.parsed_feed_top_chart_major_move_message( 4, 2, 4, country_code="us", dsp="spotify", account_id=1, move_up=False ), ] ), ), ) def test_parse_full_messages(test_logger, input_messages, expected_result_len, expected_result): from apollo_messages_views.utils.input import parse_full_events result = parse_full_events(test_logger, input_messages, event_view=EventView.PUSH) assert len(result) == expected_result_len if expected_result is not None: for i, item in enumerate(expected_result): assert result[i] == item