Source code for api.cases.v2.test_helpers.case.simple_case_search


[docs]def success(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/case, 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://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/case", 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': 'int'}, 'customer': {'id': {'type': 'int'}, 'name': {'type': 'str'}, 'shortName': {'type': 'str'}, 'domain': {'$ref': '#/definitions/DomainInfo'}}, 'service': {'id': {'type': 'int'}, 'name': {'type': 'str'}, 'shortName': {'type': 'str'}}, 'category': {'id': {'type': 'int'}, 'name': {'type': 'str'}, 'shortName': {'type': 'str'}}, 'type': 'str', 'initialStatus': {'type': 'str', 'enum': ['pendingCustomer', 'pendingSoc', 'pendingVendor', 'workingSoc', 'workingCustomer', 'pendingClose', 'closed']}, 'status': {'type': 'str', 'enum': ['pendingCustomer', 'pendingSoc', 'pendingVendor', 'workingSoc', 'workingCustomer', 'pendingClose', 'closed']}, 'initialPriority': {'type': 'str', 'enum': ['low', 'medium', 'high', 'critical']}, 'priority': {'type': 'str', 'enum': ['low', 'medium', 'high', 'critical']}, 'subject': {'type': 'str'}, 'description': {'type': 'str'}, 'customerReference': {'type': 'str'}, 'accessMode': {'type': 'str', 'enum': ['roleBased', 'readRestricted', 'writeRestricted', 'explicit']}, 'reporter': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'assignedUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'assignedTech': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'createdTimestamp': {'type': 'int'}, 'createdByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'lastUpdatedTimestamp': {'type': 'int'}, 'lastUpdatedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'closedTimestamp': {'type': 'int'}, 'closedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'publishedTimestamp': {'type': 'int'}, 'publishedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'flags': {'type': 'list', 'position': 0, 'description': 'Flags assigned to the object. ', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['DELETED', 'EXTERNAL_SYNC', 'HAS_ATTACHMENT', 'INTERNAL', 'MAIL_UPDATE', 'MERGED', 'NOTIFIED', 'PUBLISHED', 'SUBMITTED_BY_ANONYMOUS_USER', 'SUBMITTED_BY_OTHER_USER', 'DEFAULT_CONTACTS', 'DESCRIPTION_EDITED', 'SUBMITTED_BY_TECH']}}, 'properties': {'type': 'dict', 'additionalProperties': {'type': 'str'}}, 'options': ['securityIncident', 'operationalIncident', 'informational', 'change']}, '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://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/case, 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://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/case", status_code=401, json=None ) return function(*args, **kwargs) return mock_response return decorator
[docs]def forbidden(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/case, 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://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/case", status_code=403, json=None ) return function(*args, **kwargs) return mock_response return decorator
[docs]def not_found(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/case, 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://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/case", status_code=404, json=None ) return function(*args, **kwargs) return mock_response return decorator