"""Tests for ows-track Model.""" from owsrequest import request from owsrequest import test_utils from pricing.constants import service_name from pricing.models import ows_track def test_get_tracks_by_product_id(monkeypatch): """Test getting all tracks.""" mock_json_response = { 'items': [{'tuid': 1, 'product_id': 1}] } path = '/product/1/tracks' call_specs = [{ 'service': service_name.OWS_TRACK, 'path': path, 'status': 200, 'json': mock_json_response}] monkeypatch.setattr( request, 'get', test_utils.mock_ows_requests(call_specs)) response = ows_track.get_tracks_by_product_id(1) assert response.message == mock_json_response def test_get_track_by_track_id(monkeypatch): """Test getting all tracks.""" mock_json_response = { 'message': {'tuid': 1, 'product_id': 1} } path = '/track/1' call_specs = [{ 'service': service_name.OWS_TRACK, 'path': path, 'status': 200, 'json': mock_json_response}] monkeypatch.setattr( request, 'get', test_utils.mock_ows_requests(call_specs)) response = ows_track.get_track_by_track_id(1) assert response.message == mock_json_response def test_get_tracks_by_product_id_with_not_found_response(monkeypatch): """Test getting all iso territories.""" mock_json_response = {'items': []} path = '/product/1/tracks' call_specs = [{ 'service': service_name.OWS_TRACK, 'path': path, 'status': 404, 'json': mock_json_response}] monkeypatch.setattr( request, 'get', test_utils.mock_ows_requests(call_specs)) response = ows_track.get_tracks_by_product_id(1) assert response.status == 404 def test_get_grats_by_product_id(monkeypatch): """Test getting all instant grats.""" mock_json_response = { 'items': [{'tuid': 1, 'grats': [{'store_id': 1, 'active': 'Y'}]}] } path = '/product/1/tracks/grats' call_specs = [{ 'service': service_name.OWS_TRACK, 'path': path, 'status': 200, 'json': mock_json_response}] monkeypatch.setattr( request, 'get', test_utils.mock_ows_requests(call_specs)) response = ows_track.get_ig_tracks_by_product_id(1) assert response.message == mock_json_response