Source code for api.reports.v1.test_helpers.template.search_templates


[docs]def success(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/reports/v1/template/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/reports/v1/template/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', 'position': 0, 'description': 'Unique identifier of the folder/document '}, 'state': {'type': 'str', 'position': 0, 'description': 'Current state of the document ', 'enum': ['generated', 'draft', 'qa', 'approved', 'pendingDependencies', 'published', 'discarded']}, 'accessMode': {'type': 'str', 'position': 0, 'description': 'General access mode of the folder/document ', 'enum': ['roleBased', 'writeRestricted', 'readRestricted', 'explicit']}, 'effectiveAccessMode': {'type': 'str', 'position': 0, 'description': 'Effective access mode of the folder/document ', 'enum': ['roleBased', 'writeRestricted', 'readRestricted', 'explicit']}, 'currentUserAccessLevel': {'type': 'str', 'position': 0, 'description': 'Access level granted to the user viewing the folder/document ', 'enum': ['folder', 'read', 'write']}, 'name': {'type': 'str', 'position': 0, 'description': 'Name of the folder/document '}, 'masterID': {'type': 'int', 'position': 0, 'description': 'Points to the master document of this revision '}, 'revision': {'type': 'int', 'position': 0, 'description': 'Revision count '}, 'customer': {'id': {'type': 'int'}, 'name': {'type': 'str'}, 'shortName': {'type': 'str'}, 'domain': {'$ref': '#/definitions/DomainInfo'}}, 'createdTimestamp': {'type': 'int', 'position': 0, 'description': 'When the folder/document was created '}, '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', 'position': 0, 'description': 'When the folder/document was last updated '}, 'lastUpdatedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'publishedTimestamp': {'type': 'int', 'position': 0, 'description': 'When the document was published '}, 'publishDueTimestamp': {'type': 'int', 'position': 0, 'description': 'When the document must be published (due date) '}, 'lockedUntilTimestamp': {'type': 'int', 'position': 0, 'description': 'Until when the document is locked '}, 'ownedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'lockedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'publishedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'mimeType': {'type': 'str', 'position': 0, 'description': 'MIME type of the document content '}, 'dataSize': {'type': 'int', 'position': 0, 'description': 'Size of the document content in bytes '}, 'labels': {'type': 'list', 'position': 0, 'description': 'Free-text labels assigned to the document ', 'uniqueItems': True, 'items': {'type': 'str'}}, 'parentElements': {'type': 'list', 'position': 0, 'description': "Full path of the folder's/document's parent folders (ordered from root to parent folder; empty if root folder) ", 'items': {'id': {'type': 'int', 'position': 0, 'description': 'Unique identifier of the folder '}, 'name': {'type': 'str', 'position': 0, 'description': 'Name of the folder '}}}, 'documentType': {'type': 'str', 'position': 0, 'description': "Will be 'document' ", 'enum': ['report', 'document', 'template']}, 'elementType': {'type': 'str', 'position': 0, 'description': "Will be 'document' ", 'enum': ['document', 'folder']}, 'flags': {'type': 'list', 'position': 0, 'description': 'Flags assigned to the object. ', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['ATTACHMENT', 'CONTROLLED_VERSION', 'UNCOMMITTED']}}}, '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/reports/v1/template/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/reports/v1/template/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/reports/v1/template/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/reports/v1/template/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/reports/v1/template/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/reports/v1/template/search", status_code=404, json=None ) return function(*args, **kwargs) return mock_response return decorator