Source code for api.system.components.runtime.v1.host.cachedconfigurations.test_helpers.host_cachedconfigurations_clear.clear_cached_configurations


[docs]def success(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/system/components/runtime/v1/host/\w+/cachedconfigurations/clear, 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( "PUT", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/system/components/runtime/v1/host/\w+/cachedconfigurations/clear", 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'}, 'flags': {'type': 'int'}, 'scheduledDowntimeFrom': {'type': 'int'}, 'scheduledDowntimeTo': {'type': 'int'}, 'revision': {'type': 'int'}, 'masterID': {'type': 'int'}, 'createdTimestamp': {'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']}, 'information': {'type': 'str'}, 'codeProfile': {'id': {'type': 'int'}, 'name': {'type': 'str'}, 'flags': {'type': 'int'}, 'created': {'type': 'int'}, 'createdByUser': {'$ref': '#/definitions/UserInfo'}, 'lastUpdatedTimestamp': {'type': 'int'}, 'lastUpdatedByUser': {'$ref': '#/definitions/UserInfo'}, 'artifacts': {'type': 'list', 'items': {'id': {'type': 'str'}, 'groupID': {'type': 'str'}, 'artifactID': {'type': 'str'}, 'version': {'type': 'str'}, 'flags': {'type': 'int'}, 'status': {'type': 'str', 'enum': ['UNUSED', 'ACTIVE', 'DELETED']}, 'createdTimestamp': {'type': 'int'}, 'lastUpdatedTimestamp': {'type': 'int'}, 'createdByUser': {'$ref': '#/definitions/UserInfo'}, 'lastUpdatedByUser': {'$ref': '#/definitions/UserInfo'}, 'length': {'type': 'int'}, 'data': {'type': 'str'}}}, 'deleted': {'type': 'bool', 'default': False}, 'finalized': {'type': 'bool', 'default': False}}, 'properties': {'type': 'dict', 'additionalProperties': {'type': 'str'}}, 'identifiers': {'type': 'dict', 'additionalProperties': {'type': 'str'}}, 'comments': {'type': 'list', 'items': {'timestamp': {'type': 'int', 'position': 0, 'description': 'When the comment was added. '}, 'user': {'position': 0, 'description': 'Who added the comment. ', '$ref': '#/definitions/UserInfo'}, 'comment': {'type': 'str', 'position': 0, 'description': "The comment's text. "}}}, 'template': {'id': {'type': 'int'}, 'name': {'type': 'str'}, 'mnemonic': {'type': 'str'}, 'shortName': {'type': 'str'}, 'revision': {'type': 'int'}}, 'parent': {'id': {'type': 'int'}, 'revision': {'type': 'int'}, 'template': {'$ref': '#/definitions/ConfigurationTemplateInfo'}, 'host': {'$ref': '#/definitions/ConfigurationHostInfo'}, 'parent': {'$ref': '#/definitions/ConfigurationInstanceInfo'}}, 'host': {'id': {'type': 'int'}, 'name': {'type': 'str'}}}, '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/components/runtime/v1/host/\w+/cachedconfigurations/clear, 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( "PUT", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/system/components/runtime/v1/host/\w+/cachedconfigurations/clear", 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/components/runtime/v1/host/\w+/cachedconfigurations/clear, 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( "PUT", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/system/components/runtime/v1/host/\w+/cachedconfigurations/clear", 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/components/runtime/v1/host/\w+/cachedconfigurations/clear, 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( "PUT", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/system/components/runtime/v1/host/\w+/cachedconfigurations/clear", status_code=404, json=None ) return function(*args, **kwargs) return mock_response return decorator