"""HTTP test utility.""" import json from httmock import urlmatch from project_manager.constant import header_const def get_valid_header(correlation_id, account_id=7123): """Get a valid header.""" header = { header_const.CORRELATION_ID: correlation_id, header_const.GRASS_ACCOUNT_TYPE: header_const.GRASS_ACCOUNT_TYPE_VENDOR, header_const.GRASS_ACCOUNT_ID: account_id, header_const.CONTENT_TYPE: header_const.APPLICATION_JSON} return header def get_valid_oa_header(correlation_id, oa_user_id='oa:1234'): """Get a valid header.""" return { header_const.CORRELATION_ID: correlation_id, header_const.ORCHARD_USER_ID: oa_user_id, header_const.CONTENT_TYPE: header_const.APPLICATION_JSON } def get_valid_header_subaccount(correlation_id): """Get a valid subaccount header.""" header = { header_const.CORRELATION_ID: correlation_id, header_const.GRASS_ACCOUNT_TYPE: header_const.GRASS_ACCOUNT_TYPE_SUBACCOUNT, header_const.GRASS_ACCOUNT_ID: 1, header_const.CONTENT_TYPE: header_const.APPLICATION_JSON} return header @urlmatch(method='head', path=r'^.*subaccount.*$') def ows_account_is_subaccount_for_vendor_200(url, request): """ows_account return 200.""" return {'status_code': 200} @urlmatch(method='head', path=r'^.*subaccount.*$') def ows_account_is_subaccount_for_vendor_403(url, request): """ows_account return 403.""" return {'status_code': 403} @urlmatch(method='get', path=r'/highlights/project/\d+$') def get_highlight_ok(url, request): """Mock ows-marketing highlight endpoint to return 200.""" return { 'status_code': 200, 'content': json.dumps({ 'items': [{ 'scope': 'public', 'highlight_id': 39752, 'description': 'Kissed Madonna on stage at the VMAs', 'client': 'alw', 'attachment': 'N', 'mkt_program_id': 12, 'entity_id': 1900566, 'entity': 'release', 'subject': 'Project Highlights Subject'}]})}