"""Test for the ows_product module.""" from flexmock import flexmock from owsrequest import request from salessheets.models import ows_product def test_get_japan_phonetic_translations(): """Test get_japan_phonetic_translations success.""" product_id = 1 content = { 'items': [ { 'release_phonetic_translations_id': 1, 'release_id': 1, 'language_id': 24, 'phonetic_translation': 'ah' } ] } resp = flexmock( status_code=200, json=lambda: content) (flexmock(request) .should_receive('process') .and_return(resp)) result = ows_product.get_japan_phonetic_translations(product_id) assert result assert result.message == content def test_get_japan_phonetic_translations_error(): """Test get_japan_phonetic_translations error.""" product_id = 1 content = 'some error' resp = flexmock( status_code=500, content=content) (flexmock(request) .should_receive('process') .and_return(resp)) result = ows_product.get_japan_phonetic_translations(product_id) assert not result assert result.errors['message'] == content