"""Pytest fixutres for subscription-preference-sforce-updates.""" import pytest @pytest.fixture def subscription_active_off(): """Mock Subscription update.""" return { 'id': 'uuid-1', 'crmId': 'a0V0800000dG1zU', 'mailingListCrmId': 'fdasfdasfads', 'newValue': False } @pytest.fixture def subscription_active_on(): """Mock Subscription update.""" return { 'id': 'uuid-2', 'crmId': 'a0V0800000dG1zb', 'mailingListCrmId': 'fdasfdasfads', 'newValue': True } @pytest.fixture def message_updated_full(subscription_active_off, subscription_active_on): """Mock Subscription update.""" return { 'id': '5fb6ed75-f775-4384-9021-e6c9fabb7ce7', 'crmId': 'a0O0800000IhVBM', 'updatedAt': '2010-12-09T14:47:04', 'updatedSubscriptions': [ subscription_active_off, subscription_active_on ] } @pytest.fixture def message_updated_bad(subscription_active_off, subscription_active_on): """Mock Subscription update with bad datas.""" return { 'id': '5fb6ed75-f775-4384-9021-e6c9fabb7ce7', 'crmId': 'a0O0800000IhVBM', 'updatedAt': '2010-12-09T14:47:04', 'updatedSubscriptions': [ { 'id': 'uuid-1', 'newValue': False }, { 'id': 'uuid-2', 'crmId': 'b0V0800000dG1bb', 'mailingListCrmId': 'dsadsadsa', 'newValue': False }, { 'id': 'uuid-3', 'crmId': 'a0V0800000dG1zb', 'newValue': 'dummy' } ] } @pytest.fixture def message_deleted(): """Mock Subscription delete update.""" return { 'id': '5fb6ed75-f775-4384-9021-e6c9fabb7ce7', 'crmId': 'arUQAvjFGaKEesRUXnkI', 'deletedAt': '2010-12-09T14:47:04' } @pytest.fixture def message_no_fan_crmid(subscription_active_off, subscription_active_on): """Mock Subscription update message with no crmId set.""" return { 'id': '5fb6ed75-f775-4384-9021-e6c9fabb7ce7', 'crmId': None, 'updatedAt': '2010-12-09T14:47:04', 'updatedSubscriptions': [ subscription_active_off, subscription_active_on ] } @pytest.fixture def message_with_no_subscription_crmid(): """Mock Subscription update message with no updatedSubscriptions[].crmId .""" return { 'id': '5fb6ed75-f775-4384-9021-e6c9fabb7ce7', 'crmId': 'a0O0800000IhVBM', 'updatedAt': '2010-12-09T14:47:04', 'updatedSubscriptions': [ { 'id': 'uuid-1', 'crmId': None, 'mailingListCrmId': 'fdasfdasfads', 'newValue': False } ] } @pytest.fixture def message_some_missing_subscription_crmid(subscription_active_off): """Mock Subscription message with some subscriptions missing crmId.""" return { 'id': '5fb6ed75-f775-4384-9021-e6c9fabb7ce7', 'crmId': 'a0O0800000IhVBM', 'updatedAt': '2010-12-09T14:47:04', 'updatedSubscriptions': [ { 'id': 'uuid-1', 'crmId': None, 'mailingListCrmId': 'fdasfdasfads', 'newValue': False }, subscription_active_off ] }