"""Tests for ows_track model.""" from owsrequest import request import pytest from conflict_manager.constants import query_parameters from conflict_manager.constants import services from conflict_manager.models import ows_masters_registry @pytest.fixture def items(): """Remove ownership test items.""" return [ { 'conflict_date': '2018-02-22', 'conflicting_owner': 'believe_africa', 'isrc': 'QM6MZ1783179', 'territories': ['BR', 'HT'], 'tuid': '25874822' }, { 'conflict_date': '2018-02-22', 'conflicting_owner': 'rumblefish_cdbaby', 'isrc': 'USA370311852', 'territories': ['HT'], 'tuid': '32511' }, ] def test_remove_ownership(mocker, items): """Test bulk_remove_territories function.""" account_type = 'vendor' account_id = '961' correlation_id = '12098765' endpoint = '/ownership/territories' params = { query_parameters.ACCOUNT_TYPE: account_type, query_parameters.ACCOUNT_ID: account_id, } mocked_response = {'status': 'OK'} response = mocker.MagicMock(status_code=200, json=lambda: mocked_response) del_mock = mocker.patch.object(request, 'delete', return_value=response) headers = { 'Orchard-User-Id': 'alw:123', 'Content-Type': 'application/json' } ows_response = ows_masters_registry.bulk_remove_territories( items, account_type, account_id, correlation_id, 'alw:123') assert ows_response.message == mocked_response del_mock.assert_called_with( services.OWS_MASTERS_REGISTRY, endpoint, json={'items': items}, params=params, correlation_id=correlation_id, headers=headers)