Source code for api.system.notification.v1.test_helpers.rule.list


[docs]def success(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/system/notification/v1/rule/search, 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( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/system/notification/v1/rule/search", 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'}, 'revision': {'type': 'int'}, 'name': {'type': 'str'}, 'matchRule': {'type': 'str'}, 'customer': {'id': {'type': 'int'}, 'name': {'type': 'str'}, 'shortName': {'type': 'str'}, 'domain': {'$ref': '#/definitions/DomainInfo'}}, 'index': {'type': 'int'}, 'flags': {'type': 'int'}, 'actions': {'type': 'list', 'items': {'changeMatching': {'type': 'str', 'xml': {'name': 'ChangeMatching'}, 'description': '[\\s\\w\\{\\}\\$\\-\\(\\)\\.\\[\\]"\\\'_/\\\\,\\*\\+\\#:@!?;]*'}, 'changeTypes': {'type': 'list', 'xml': {'name': 'Type', 'wrapped': True}, 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['SMS', 'EMAIL']}}, 'changeFormats': {'type': 'list', 'xml': {'name': 'Format', 'wrapped': True}, 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['BRIEF', 'FULL']}}, 'changeRoles': {'type': 'list', 'xml': {'name': 'Role', 'wrapped': True}, 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['SERVICE_CONTACT', 'CONTACT', 'WATCHER', 'CC', 'OWNER', 'TECH', 'REPORTER', 'CURRENT_USER']}}, 'sender': {'type': 'str', 'xml': {'name': 'Sender'}}, 'setFlags': {'type': 'int', 'xml': {'name': 'SetFlags'}}, 'unsetFlags': {'type': 'int', 'xml': {'name': 'UnsetFlags'}}, 'subjectTemplate': {'type': 'dict', 'xml': {'name': 'SubjectTemplate', 'wrapped': True}, 'description': 'format:html', 'additionalProperties': {'type': 'str'}}, 'bodyTemplate': {'type': 'dict', 'xml': {'name': 'BodyTemplate', 'wrapped': True}, 'description': 'format:html', 'additionalProperties': {'type': 'str'}}, 'smsTemplate': {'type': 'dict', 'xml': {'name': 'SMSTemplate', 'wrapped': True}, 'description': '[\\s\\w\\{\\}\\$\\-\\(\\)\\.\\[\\]"\\\'_/\\\\,\\*\\+\\#:@!?;]*', 'additionalProperties': {'type': 'str'}}}}, 'additionalDestinations': {'type': 'list', 'items': {'type': 'str', 'role': {'type': 'str', 'xml': {'name': 'Role'}, 'enum': ['SERVICE_CONTACT', 'CONTACT', 'WATCHER', 'CC', 'OWNER', 'TECH', 'REPORTER', 'CURRENT_USER']}, 'name': {'type': 'str', 'xml': {'name': 'Name'}, 'description': '[\\s\\w\\{\\}\\$\\-\\(\\)\\.\\[\\]"\\\'_/\\\\,\\*\\+\\#:@!?;]*'}, 'destination': {'type': 'str', 'xml': {'name': 'Destination'}}, 'language': {'type': 'str', 'xml': {'name': 'Language'}, 'enum': ['ENGLISH', 'NORWEGIAN']}, 'flags': {'type': 'int', 'xml': {'name': 'Flags'}}, 'options': ['SMS', 'EMAIL']}}, 'timestamp': {'type': 'int'}, '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']}, 'events': {'type': 'list', 'uniqueItems': True, 'items': {'type': 'str'}}, 'globalCustomer': {'type': 'bool', 'default': False}}, '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/system/notification/v1/rule/search, 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( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/system/notification/v1/rule/search", 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/system/notification/v1/rule/search, 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( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/system/notification/v1/rule/search", 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/system/notification/v1/rule/search, 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( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/system/notification/v1/rule/search", status_code=404, json=None ) return function(*args, **kwargs) return mock_response return decorator