Source code for api.sensors.v1.test_helpers.status.list_sensors


[docs]def success(function): """Mock https://portal.mnemonic.no/web/api/sensors/v1/status, 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/sensors/v1/status", 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': {'lastEventTimestamp': {'type': 'int'}, 'lastUpdateTimestamp': {'type': 'int'}, 'messageRate': {'type': 'int'}, 'lastAgentHost': {'type': 'str'}, 'sensor': {'id': {'type': 'int'}, 'customer': {'$ref': '#/definitions/CustomerInfo'}, 'application': {'$ref': '#/definitions/Application'}, 'clusterSensor': {'$ref': '#/definitions/SensorInfo'}, 'expectedUpdateTime': {'type': 'int'}, 'scheduledDowntimeFromTime': {'type': 'int'}, 'scheduledDowntimeUntilTime': {'type': 'int'}, 'information': {'type': 'str'}, 'hostname': {'type': 'str'}, 'additionalData': {'type': 'str'}, 'flags': {'type': 'list', 'position': 0, 'description': 'Flags assigned to the object. ', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['ACTIVE', 'MONITORED', 'SIEM', 'DELETED', 'OVERRIDE_UPDATE_TIME', 'MONITORED_ONLY_DAYTIME', 'SHARED_CUSTOMER_DATA', 'ACKNOWLEDGED', 'KEEP_DOWNTIME_ON_UPDATE', 'CLOCK_OUT_OF_SYNC']}}, 'lastUpdatedByUser': {'$ref': '#/definitions/UserInfo'}, 'lastUpdatedTimestamp': {'type': 'int'}, 'lastAcknowledgedTimestamp': {'type': 'int'}, 'inScheduledDowntime': {'type': 'bool', 'default': False}, 'ipaddress': {'$ref': '#/definitions/IPAddress'}, 'location': {'$ref': '#/definitions/LocationInfo'}}}, '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/sensors/v1/status, 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/sensors/v1/status", status_code=401, json=None ) return function(*args, **kwargs) return mock_response return decorator
[docs]def forbidden(function): """Mock https://portal.mnemonic.no/web/api/sensors/v1/status, 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/sensors/v1/status", 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/sensors/v1/status, 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/sensors/v1/status", status_code=404, json=None ) return function(*args, **kwargs) return mock_response return decorator