[docs]def success(function):
"""Mock https://portal.mnemonic.no/web/api/cases/v2/case/\w+/links, respond with HTTP 200"""
import requests_mock
from argus_api.helpers.tests import fake_response
def mock_response(*args, **kwargs):
with requests_mock.Mocker(real_http=True) as mock:
mock.register_uri(
"GET",
r"https://portal.mnemonic.no/web/api/cases/v2/case/\w+/links",
status_code=200,
json=fake_response({'offset': {'type': 'int', 'name': 'offset'}, 'limit': {'type': 'int', 'name': 'limit'}, 'responseCode': {'type': 'int', 'name': 'responseCode'}, 'count': {'type': 'int', 'name': 'count'}, 'data': {'type': 'list', 'items': {'id': {'type': 'str'}, 'addedTimestamp': {'type': 'int', 'position': 0, 'description': 'Timestamp when this value was added '}, 'addedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'linkedCase': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'subject': {'type': 'str'}, 'service': {'type': 'str'}, 'status': {'type': 'str', 'enum': ['pendingCustomer', 'pendingSoc', 'pendingVendor', 'workingSoc', 'workingCustomer', 'pendingClose', 'closed']}, 'priority': {'type': 'str', 'enum': ['low', 'medium', 'high', 'critical']}, 'caseID': {'type': 'int'}}, 'flags': {'type': 'list', 'position': 0, 'description': 'Flags assigned to the object. ', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['DELETED', 'MERGED']}}, 'type': 'str', 'direction': {'type': 'str', 'position': 0, 'description': 'The direction of this link (incoming if this is a link TO the requested case, outgoing if this is a link FROM the requested case) ', 'enum': ['incoming', 'outgoing']}, 'parentCase': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'subject': {'type': 'str'}, 'service': {'type': 'str'}, 'status': {'type': 'str', 'enum': ['pendingCustomer', 'pendingSoc', 'pendingVendor', 'workingSoc', 'workingCustomer', 'pendingClose', 'closed']}, 'priority': {'type': 'str', 'enum': ['low', 'medium', 'high', 'critical']}, 'caseID': {'type': 'int'}}, 'options': ['merged', 'subcase', 'related', 'duplicate', 'dependency']}, 'name': 'data'}, 'metaData': {'type': 'dict', 'additionalProperties': {'type': 'dict'}, 'name': 'metaData'}, 'messages': {'type': 'list', 'items': {'message': {'type': 'str'}, 'messageTemplate': {'type': 'str'}, 'type': 'str', 'field': {'type': 'str'}, 'parameter': {'type': 'dict'}, 'timestamp': {'type': 'int'}, 'options': ['FIELD_ERROR', 'ACTION_ERROR', 'WARNING', 'NOTIFICATION', 'INFO']}, 'name': 'messages'}, 'currentPage': {'type': 'int', 'name': 'currentPage'}, 'size': {'type': 'int', 'name': 'size'}})
)
return function(*args, **kwargs)
return mock_response
return decorator
[docs]def unauthorized(function):
"""Mock https://portal.mnemonic.no/web/api/cases/v2/case/\w+/links, respond with HTTP 401"""
import requests_mock
from argus_api.helpers.tests import fake_response
def mock_response(*args, **kwargs):
with requests_mock.Mocker(real_http=True) as mock:
mock.register_uri(
"GET",
r"https://portal.mnemonic.no/web/api/cases/v2/case/\w+/links",
status_code=401,
json=None
)
return function(*args, **kwargs)
return mock_response
return decorator
[docs]def access_denied(function):
"""Mock https://portal.mnemonic.no/web/api/cases/v2/case/\w+/links, respond with HTTP 403"""
import requests_mock
from argus_api.helpers.tests import fake_response
def mock_response(*args, **kwargs):
with requests_mock.Mocker(real_http=True) as mock:
mock.register_uri(
"GET",
r"https://portal.mnemonic.no/web/api/cases/v2/case/\w+/links",
status_code=403,
json=None
)
return function(*args, **kwargs)
return mock_response
return decorator
[docs]def not_found(function):
"""Mock https://portal.mnemonic.no/web/api/cases/v2/case/\w+/links, respond with HTTP 404"""
import requests_mock
from argus_api.helpers.tests import fake_response
def mock_response(*args, **kwargs):
with requests_mock.Mocker(real_http=True) as mock:
mock.register_uri(
"GET",
r"https://portal.mnemonic.no/web/api/cases/v2/case/\w+/links",
status_code=404,
json=None
)
return function(*args, **kwargs)
return mock_response
return decorator