"""Test for product logic layer.""" from unittest.mock import MagicMock from oto import response from pricing.logic import product from pricing.models import ows_product import pytest @pytest.fixture def fixture_success(): """Get a response.""" return response.Response('ok') def test_is_owner(monkeypatch, fixture_success): """Test getting whether user is product owner.""" monkeypatch.setattr(ows_product, 'is_owner', MagicMock( return_value=fixture_success)) result = product.is_owner('any', 'thing', 'here') assert result assert result.message == fixture_success.message def test_get_product_ids_from_upcs(monkeypatch, fixture_success): """Test getting whether user is product owner.""" monkeypatch.setattr(ows_product, 'get_product_ids_from_upcs', MagicMock( return_value=fixture_success)) result = product.get_product_ids_from_upcs(['123', '456']) assert result assert result.status == 200