"""Test logic for notifications.""" from owsresponse import response import pytest from users.constants import LABEL_PROFILE from users.logic import notifications from users.models import ows_notifications @pytest.mark.parametrize( ('vendor_id', 'subaccount_id', 'model_called'), [ [8869, None, True], [8869, 5500, True], [None, 5500, True], [None, None, False], ], ) def test_unsubscribe_label(vendor_id, subaccount_id, model_called, mocker): """Test unsubscribe_label.""" profile_id = 1234 mocker.patch.object( ows_notifications, 'unsubscribe_label', return_value=response.Response('success') ) notifications.unsubscribe_labelprofile(profile_id, vendor_id, subaccount_id) if model_called: ows_notifications.unsubscribe_label.assert_called_with( profile_id, LABEL_PROFILE, vendor_id, subaccount_id ) @pytest.mark.parametrize( ('vendor_id', 'subaccount_id', 'model_called'), [ [8869, None, True], [8869, 5500, True], [None, 5500, True], [None, None, False], ], ) def test_subscribe_labelprofile(vendor_id, subaccount_id, model_called, mocker): """Test subscribe_labelprofile.""" profile_id = 1234 mocker.patch.object( ows_notifications, 'subscribe_label', return_value=response.Response('success') ) notifications.subscribe_labelprofile(profile_id, vendor_id, subaccount_id) if model_called: ows_notifications.subscribe_label.assert_called_with( profile_id, LABEL_PROFILE, vendor_id, subaccount_id, True )