"""Unit tests for Product logic.""" from owsrequest import request as requests from owsrequest import test_utils from promo_player.constants import service_name from promo_player.logic import product def test_is_owner(monkeypatch): """Test checking ownership of a product.""" account_type = 'vendor' account_id = '123' product_id = 456 expected_status = 342 path = '/{account_type}/{account_id}/product/{product_id}'.format( account_type=account_type, account_id=account_id, product_id=product_id) call_specs = [{ 'service': service_name.OWS_PRODUCT, 'path': path, 'status': expected_status }] monkeypatch.setattr( requests, 'head', test_utils.mock_ows_requests(call_specs)) response = product.is_owner(product_id, account_type, account_id) assert response.status == expected_status