"""Test for ows-account model.""" from unittest.mock import call from flask import g from owsrequest import request from owsrequest import test_utils import pytest from product_digital.models import ows_account @pytest.mark.parametrize(( 'test_description', 'response_status', 'response_json', 'expected_g_log_error_calls', 'expected_result', ), [ ( 'success 200', 200, 'theorchard', [], '"theorchard"', ), ( 'error 123454321', 500, 'N/A', [call('ows-account returned unexpected status_code of 500')], None, ), ]) def test_get_vendor_company_brand( monkeypatch, mocker, test_request_context, test_description, response_status, response_json, expected_g_log_error_calls, expected_result, ): """Test get_vendor_company_brand.""" get_specs = [{ 'service': 'ows-account', 'path': '/vendor/brand/1232', 'status': response_status, 'json': response_json}] monkeypatch.setattr( request, 'get', test_utils.mock_ows_requests(get_specs)) result = ows_account.get_vendor_company_brand(1232) assert g.log.error.mock_calls == expected_g_log_error_calls assert result == expected_result