diff --git a/forthic/global_module.py b/forthic/global_module.py
index 66d3c5b..48c29a9 100644
--- a/forthic/global_module.py
+++ b/forthic/global_module.py
@@ -20,7 +20,6 @@
from typing import Optional, Union, Any, List
-
DLE = chr(16) # ASCII DLE char
diff --git a/tests/tests_py/modules/confluence_context.py b/tests/tests_py/modules/confluence_context.py
index 24c3036..039ad68 100644
--- a/tests/tests_py/modules/confluence_context.py
+++ b/tests/tests_py/modules/confluence_context.py
@@ -1,886 +1,886 @@
-import json
-from forthic.modules.confluence_module import ConfluenceContext
-
-class ServerResponse:
- def __init__(self, string, status_code=200):
- self.json_string = string
- self.status_code = status_code
- self.text = ""
-
- def json(self):
- result = json.loads(self.json_string)
- return result
-
-
-
-class ConfluenceTestContext(ConfluenceContext):
- def __init__(self):
- self.page_created = False
-
- def get_host(self):
- return "http://testcontext"
-
- def requests_get(self, api_url):
- result = ServerResponse("null")
- if api_url == '/wiki/cf/rest/api/content?title=A+page+title&spaceKey=SPACE&expand=version':
- result = ServerResponse(PAGE_INFO_RESPONSE)
- elif not self.page_created and api_url == '/wiki/cf/rest/api/content?title=A+new+page+title&spaceKey=SPACE&expand=ancestors':
- result = ServerResponse(NO_PAGE_INFO_RESPONSE)
- elif self.page_created and api_url == '/wiki/cf/rest/api/content?title=A+new+page+title&spaceKey=SPACE&expand=ancestors':
- result = ServerResponse(PAGE_INFO_w_ANCESTORS_RESPONSE)
- elif api_url == '/wiki/cf/rest/api/content?title=A+parent+title&spaceKey=SPACE&expand=version':
- result = ServerResponse(PAGE_INFO_RESPONSE)
- elif api_url == '/wiki/cf/rest/api/content?title=A+new+page+title&spaceKey=SPACE&expand=version':
- result = ServerResponse(PAGE_INFO_RESPONSE)
- else:
- raise Exception(f"Unknown route: {api_url}")
- return result
-
- def requests_post(self, api_url, json=None):
- result = ServerResponse("null")
- if api_url == "/wiki/cf/rest/api/content":
- self.page_created = True
- result = ServerResponse(CREATE_PAGE_RESPONSE)
- else:
- raise Exception(f"Unknown route: {api_url}")
- return result
-
- def requests_put(self, api_url, json=None):
- result = ServerResponse("null")
- if api_url == '/wiki/cf/rest/api/content/1234':
- result = ServerResponse(UPDATE_PAGE_RESPONSE)
- else:
- raise Exception(f"Unknown route: {api_url}")
- return result
-
-
-PAGE_INFO_RESPONSE = '''
-{
- "results": [
- {
- "id": "1234",
- "type": "page",
- "status": "current",
- "title": "A page title",
- "version": {
- "by": {
- "type": "known",
- "username": "testuser",
- "userKey": "2c9239b948dc82440148dc876925181a",
- "profilePicture": {
- "path": "/wiki/cf/images/icons/profilepics/default.svg",
- "width": 48,
- "height": 48,
- "isDefault": true
- },
- "displayName": "Test User",
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc876925181a"
- },
- "_expandable": {
- "status": ""
- }
- },
- "when": "2020-10-23T16:54:50.000Z",
- "message": "",
- "number": 3,
- "minorEdit": false,
- "hidden": false,
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/experimental/content/1234/version/3"
- },
- "_expandable": {
- "content": "/rest/api/content/1234"
- }
- },
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/A+page+title",
- "edit": "/pages/resumedraft.action?draftId=1234&draftShareId=0b59bcea-e6ea-44cc-a0b1-745f7d9e441d",
- "tinyui": "/x/chcmFw",
- "self": "https://testcontext/wiki/cf/rest/api/content/1234"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/1234/child",
- "restrictions": "/rest/api/content/1234/restriction/byOperation",
- "history": "/rest/api/content/1234/history",
- "ancestors": "",
- "body": "",
- "descendants": "/rest/api/content/1234/descendant",
- "space": "/rest/api/space/SPACE"
- }
- }
- ],
- "start": 0,
- "limit": 25,
- "size": 1,
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/content?spaceKey=SPACE&expand=version&title=A%20page%20title",
- "base": "https://testcontext/wiki/cf",
- "context": "/wiki/cf"
- }
-}
-'''
-
-NO_PAGE_INFO_RESPONSE ='''
-{
- "results": [],
- "start": 0,
- "limit": 25,
- "size": 0,
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/content?spaceKey=SPACE&expand=ancestors&title=A%20new%20page%20title",
- "base": "https://testcontext/wiki/cf",
- "context": "/wiki/cf"
- }
-}
-'''
-
-PAGE_INFO_w_ANCESTORS_RESPONSE = '''
-{
- "results": [
- {
- "id": "388386405",
- "type": "page",
- "status": "current",
- "title": "A new page title",
- "ancestors": [
- {
- "id": "119239646",
- "type": "page",
- "status": "current",
- "title": "Space Home",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Space+Home",
- "edit": "/pages/resumedraft.action?draftId=119239646",
- "tinyui": "/x/3nMbBw",
- "self": "https://testcontext/wiki/cf/rest/api/content/119239646"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/119239646/child",
- "restrictions": "/rest/api/content/119239646/restriction/byOperation",
- "history": "/rest/api/content/119239646/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/119239646/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "148348821",
- "type": "page",
- "status": "current",
- "title": "Project SPACE",
- "extensions": {
- "position": 85
- },
- "_links": {
- "webui": "/display/SPACE/Project+SPACE",
- "edit": "/pages/resumedraft.action?draftId=148348821",
- "tinyui": "/x/lZ-XC",
- "self": "https://testcontext/wiki/cf/rest/api/content/148348821"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/148348821/child",
- "restrictions": "/rest/api/content/148348821/restriction/byOperation",
- "history": "/rest/api/content/148348821/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/148348821/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "148348824",
- "type": "page",
- "status": "current",
- "title": "Forthic",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Forthic",
- "edit": "/pages/resumedraft.action?draftId=148348824",
- "tinyui": "/x/mJ-XC",
- "self": "https://testcontext/wiki/cf/rest/api/content/148348824"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/148348824/child",
- "restrictions": "/rest/api/content/148348824/restriction/byOperation",
- "history": "/rest/api/content/148348824/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/148348824/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "248042769",
- "type": "page",
- "status": "current",
- "title": "Forthic Framework",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Forthic+Framework",
- "edit": "/pages/resumedraft.action?draftId=248042769&draftShareId=e6dfb6e9-9a98-4e20-8afc-8fdfaa354ace",
- "tinyui": "/x/EdXIDg",
- "self": "https://testcontext/wiki/cf/rest/api/content/248042769"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/248042769/child",
- "restrictions": "/rest/api/content/248042769/restriction/byOperation",
- "history": "/rest/api/content/248042769/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/248042769/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "261397943",
- "type": "page",
- "status": "current",
- "title": "A parent title",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Forthic+Testing",
- "edit": "/pages/resumedraft.action?draftId=261397943&draftShareId=5ebe725d-0d69-46a5-bf3f-5cd01d7c17c7",
- "tinyui": "/x/t52UDw",
- "self": "https://testcontext/wiki/cf/rest/api/content/261397943"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/261397943/child",
- "restrictions": "/rest/api/content/261397943/restriction/byOperation",
- "history": "/rest/api/content/261397943/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/261397943/descendant",
- "space": "/rest/api/space/SPACE"
- }
- }
- ],
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/A+new+page+title",
- "edit": "/pages/resumedraft.action?draftId=388386405",
- "tinyui": "/x/ZU4mFw",
- "self": "https://testcontext/wiki/cf/rest/api/content/388386405"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/388386405/child",
- "restrictions": "/rest/api/content/388386405/restriction/byOperation",
- "history": "/rest/api/content/388386405/history",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/388386405/descendant",
- "space": "/rest/api/space/SPACE"
- }
- }
- ],
- "start": 0,
- "limit": 25,
- "size": 1,
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/content?spaceKey=SPACE&expand=ancestors&title=A%20new%20page%20title",
- "base": "https://testcontext/wiki/cf",
- "context": "/wiki/cf"
- }
-}
-'''
-
-
-CREATE_PAGE_RESPONSE='''
-{
- "id": "388386403",
- "type": "page",
- "status": "current",
- "title": "A new page title",
- "space": {
- "id": 119963668,
- "key": "SPACE",
- "name": "Space",
- "type": "global",
- "_links": {
- "webui": "/display/SPACE",
- "self": "https://testcontext/wiki/cf/rest/api/space/SPACE"
- },
- "_expandable": {
- "metadata": "",
- "icon": "",
- "description": "",
- "homepage": "/rest/api/content/119239646"
- }
- },
- "history": {
- "latest": true,
- "createdBy": {
- "type": "known",
- "username": "SPACE-auto",
- "userKey": "2c9239b948dc82440148dc875dc709a1",
- "profilePicture": {
- "path": "/wiki/cf/images/icons/profilepics/default.svg",
- "width": 48,
- "height": 48,
- "isDefault": true
- },
- "displayName": "SPACE-auto",
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc875dc709a1"
- },
- "_expandable": {
- "status": ""
- }
- },
- "createdDate": "2020-10-30T15:48:59.311Z",
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/content/388386403/history"
- },
- "_expandable": {
- "lastUpdated": "",
- "previousVersion": "",
- "contributors": "",
- "nextVersion": ""
- }
- },
- "version": {
- "by": {
- "type": "known",
- "username": "SPACE-auto",
- "userKey": "2c9239b948dc82440148dc875dc709a1",
- "profilePicture": {
- "path": "/wiki/cf/images/icons/profilepics/default.svg",
- "width": 48,
- "height": 48,
- "isDefault": true
- },
- "displayName": "SPACE-auto",
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc875dc709a1"
- },
- "_expandable": {
- "status": ""
- }
- },
- "when": "2020-10-30T15:48:59.311Z",
- "message": "",
- "number": 1,
- "minorEdit": false,
- "hidden": false,
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/experimental/content/388386403/version/1"
- },
- "_expandable": {
- "content": "/rest/api/content/388386403"
- }
- },
- "ancestors": [
- {
- "id": "119239646",
- "type": "page",
- "status": "current",
- "title": "Space Home",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Space+Home",
- "edit": "/pages/resumedraft.action?draftId=119239646",
- "tinyui": "/x/3nMbBw",
- "self": "https://testcontext/wiki/cf/rest/api/content/119239646"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/119239646/child",
- "restrictions": "/rest/api/content/119239646/restriction/byOperation",
- "history": "/rest/api/content/119239646/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/119239646/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "148348821",
- "type": "page",
- "status": "current",
- "title": "Project SPACE",
- "extensions": {
- "position": 85
- },
- "_links": {
- "webui": "/display/SPACE/Project+SPACE",
- "edit": "/pages/resumedraft.action?draftId=148348821",
- "tinyui": "/x/lZ-XC",
- "self": "https://testcontext/wiki/cf/rest/api/content/148348821"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/148348821/child",
- "restrictions": "/rest/api/content/148348821/restriction/byOperation",
- "history": "/rest/api/content/148348821/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/148348821/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "148348824",
- "type": "page",
- "status": "current",
- "title": "Forthic",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Forthic",
- "edit": "/pages/resumedraft.action?draftId=148348824",
- "tinyui": "/x/mJ-XC",
- "self": "https://testcontext/wiki/cf/rest/api/content/148348824"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/148348824/child",
- "restrictions": "/rest/api/content/148348824/restriction/byOperation",
- "history": "/rest/api/content/148348824/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/148348824/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "248042769",
- "type": "page",
- "status": "current",
- "title": "Forthic Framework",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Forthic+Framework",
- "edit": "/pages/resumedraft.action?draftId=248042769&draftShareId=e6dfb6e9-9a98-4e20-8afc-8fdfaa354ace",
- "tinyui": "/x/EdXIDg",
- "self": "https://testcontext/wiki/cf/rest/api/content/248042769"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/248042769/child",
- "restrictions": "/rest/api/content/248042769/restriction/byOperation",
- "history": "/rest/api/content/248042769/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/248042769/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "261397943",
- "type": "page",
- "status": "current",
- "title": "A parent title",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Forthic+Testing",
- "edit": "/pages/resumedraft.action?draftId=261397943&draftShareId=5ebe725d-0d69-46a5-bf3f-5cd01d7c17c7",
- "tinyui": "/x/t52UDw",
- "self": "https://testcontext/wiki/cf/rest/api/content/261397943"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/261397943/child",
- "restrictions": "/rest/api/content/261397943/restriction/byOperation",
- "history": "/rest/api/content/261397943/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/261397943/descendant",
- "space": "/rest/api/space/SPACE"
- }
- }
- ],
- "container": {
- "id": 119963668,
- "key": "SPACE",
- "name": "Space",
- "type": "global",
- "_links": {
- "webui": "/display/SPACE",
- "self": "https://testcontext/wiki/cf/rest/api/space/SPACE"
- },
- "_expandable": {
- "metadata": "",
- "icon": "",
- "description": "",
- "homepage": "/rest/api/content/119239646"
- }
- },
- "body": {
- "storage": {
- "value": "
This is a test
",
- "representation": "storage",
- "_expandable": {
- "content": "/rest/api/content/388386403"
- }
- },
- "_expandable": {
- "editor": "",
- "view": "",
- "export_view": "",
- "styled_view": "",
- "anonymous_export_view": ""
- }
- },
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/A+new+page+title",
- "edit": "/pages/resumedraft.action?draftId=388386403",
- "tinyui": "/x/Y04mFw",
- "collection": "/rest/api/content",
- "base": "https://testcontext/wiki/cf",
- "context": "/wiki/cf",
- "self": "https://testcontext/wiki/cf/rest/api/content/388386403"
- },
- "_expandable": {
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/388386403/child",
- "restrictions": "/rest/api/content/388386403/restriction/byOperation",
- "descendants": "/rest/api/content/388386403/descendant"
- }
-}
-'''
-
-UPDATE_PAGE_RESPONSE = '''
-{
- "id": "1234",
- "type": "page",
- "status": "current",
- "title": "A new page title",
- "space": {
- "id": 119963668,
- "key": "SPACE",
- "name": "SPACE",
- "type": "global",
- "_links": {
- "webui": "/display/SPACE",
- "self": "https://testcontext/wiki/cf/rest/api/space/SPACE"
- },
- "_expandable": {
- "metadata": "",
- "icon": "",
- "description": "",
- "homepage": "/rest/api/content/119239646"
- }
- },
- "history": {
- "latest": true,
- "createdBy": {
- "type": "known",
- "username": "SPACE-auto",
- "userKey": "2c9239b948dc82440148dc875dc709a1",
- "profilePicture": {
- "path": "/wiki/cf/images/icons/profilepics/default.svg",
- "width": 48,
- "height": 48,
- "isDefault": true
- },
- "displayName": "SPACE-auto",
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc875dc709a1"
- },
- "_expandable": {
- "status": ""
- }
- },
- "createdDate": "2020-10-30T15:58:05.590Z",
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/content/388386405/history"
- },
- "_expandable": {
- "lastUpdated": "",
- "previousVersion": "",
- "contributors": "",
- "nextVersion": ""
- }
- },
- "version": {
- "by": {
- "type": "known",
- "username": "SPACE-auto",
- "userKey": "2c9239b948dc82440148dc875dc709a1",
- "profilePicture": {
- "path": "/wiki/cf/images/icons/profilepics/default.svg",
- "width": 48,
- "height": 48,
- "isDefault": true
- },
- "displayName": "SPACE-auto",
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc875dc709a1"
- },
- "_expandable": {
- "status": ""
- }
- },
- "when": "2020-10-30T16:29:18.318Z",
- "number": 2,
- "minorEdit": false,
- "hidden": false,
- "_links": {
- "self": "https://testcontext/wiki/cf/rest/experimental/content/388386405/version/2"
- },
- "_expandable": {
- "content": "/rest/api/content/388386405"
- }
- },
- "ancestors": [
- {
- "id": "119239646",
- "type": "page",
- "status": "current",
- "title": "SPACE Home",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/SPACE+Home",
- "edit": "/pages/resumedraft.action?draftId=119239646",
- "tinyui": "/x/3nMbBw",
- "self": "https://testcontext/wiki/cf/rest/api/content/119239646"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/119239646/child",
- "restrictions": "/rest/api/content/119239646/restriction/byOperation",
- "history": "/rest/api/content/119239646/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/119239646/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "148348821",
- "type": "page",
- "status": "current",
- "title": "Project SPACE",
- "extensions": {
- "position": 85
- },
- "_links": {
- "webui": "/display/SPACE/Project+SPACE",
- "edit": "/pages/resumedraft.action?draftId=148348821",
- "tinyui": "/x/lZ-XC",
- "self": "https://testcontext/wiki/cf/rest/api/content/148348821"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/148348821/child",
- "restrictions": "/rest/api/content/148348821/restriction/byOperation",
- "history": "/rest/api/content/148348821/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/148348821/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "148348824",
- "type": "page",
- "status": "current",
- "title": "Forthic",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Forthic",
- "edit": "/pages/resumedraft.action?draftId=148348824",
- "tinyui": "/x/mJ-XC",
- "self": "https://testcontext/wiki/cf/rest/api/content/148348824"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/148348824/child",
- "restrictions": "/rest/api/content/148348824/restriction/byOperation",
- "history": "/rest/api/content/148348824/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/148348824/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "248042769",
- "type": "page",
- "status": "current",
- "title": "Forthic Framework",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Forthic+Framework",
- "edit": "/pages/resumedraft.action?draftId=248042769&draftShareId=e6dfb6e9-9a98-4e20-8afc-8fdfaa354ace",
- "tinyui": "/x/EdXIDg",
- "self": "https://testcontext/wiki/cf/rest/api/content/248042769"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/248042769/child",
- "restrictions": "/rest/api/content/248042769/restriction/byOperation",
- "history": "/rest/api/content/248042769/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/248042769/descendant",
- "space": "/rest/api/space/SPACE"
- }
- },
- {
- "id": "261397943",
- "type": "page",
- "status": "current",
- "title": "Forthic Testing",
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/Forthic+Testing",
- "edit": "/pages/resumedraft.action?draftId=261397943&draftShareId=5ebe725d-0d69-46a5-bf3f-5cd01d7c17c7",
- "tinyui": "/x/t52UDw",
- "self": "https://testcontext/wiki/cf/rest/api/content/261397943"
- },
- "_expandable": {
- "container": "/rest/api/space/SPACE",
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/261397943/child",
- "restrictions": "/rest/api/content/261397943/restriction/byOperation",
- "history": "/rest/api/content/261397943/history",
- "ancestors": "",
- "body": "",
- "version": "",
- "descendants": "/rest/api/content/261397943/descendant",
- "space": "/rest/api/space/SPACE"
- }
- }
- ],
- "container": {
- "id": 119963668,
- "key": "SPACE",
- "name": "SPACE",
- "type": "global",
- "_links": {
- "webui": "/display/SPACE",
- "self": "https://testcontext/wiki/cf/rest/api/space/SPACE"
- },
- "_expandable": {
- "metadata": "",
- "icon": "",
- "description": "",
- "homepage": "/rest/api/content/119239646"
- }
- },
- "body": {
- "storage": {
- "value": "This is second a test
",
- "representation": "storage",
- "_expandable": {
- "content": "/rest/api/content/388386405"
- }
- },
- "_expandable": {
- "editor": "",
- "view": "",
- "export_view": "",
- "styled_view": "",
- "anonymous_export_view": ""
- }
- },
- "extensions": {
- "position": "none"
- },
- "_links": {
- "webui": "/display/SPACE/A+new+page+title",
- "edit": "/pages/resumedraft.action?draftId=388386405",
- "tinyui": "/x/ZU4mFw",
- "collection": "/rest/api/content",
- "base": "https://testcontext/wiki/cf",
- "context": "/wiki/cf",
- "self": "https://testcontext/wiki/cf/rest/api/content/388386405"
- },
- "_expandable": {
- "metadata": "",
- "operations": "",
- "children": "/rest/api/content/388386405/child",
- "restrictions": "/rest/api/content/388386405/restriction/byOperation",
- "descendants": "/rest/api/content/388386405/descendant"
- }
-}
+import json
+from forthic.modules.confluence_module import ConfluenceContext
+
+
+class ServerResponse:
+ def __init__(self, string, status_code=200):
+ self.json_string = string
+ self.status_code = status_code
+ self.text = ""
+
+ def json(self):
+ result = json.loads(self.json_string)
+ return result
+
+
+class ConfluenceTestContext(ConfluenceContext):
+ def __init__(self):
+ self.page_created = False
+
+ def get_host(self):
+ return "http://testcontext"
+
+ def requests_get(self, api_url):
+ result = ServerResponse("null")
+ if api_url == '/wiki/cf/rest/api/content?title=A+page+title&spaceKey=SPACE&expand=version':
+ result = ServerResponse(PAGE_INFO_RESPONSE)
+ elif not self.page_created and api_url == '/wiki/cf/rest/api/content?title=A+new+page+title&spaceKey=SPACE&expand=ancestors':
+ result = ServerResponse(NO_PAGE_INFO_RESPONSE)
+ elif self.page_created and api_url == '/wiki/cf/rest/api/content?title=A+new+page+title&spaceKey=SPACE&expand=ancestors':
+ result = ServerResponse(PAGE_INFO_w_ANCESTORS_RESPONSE)
+ elif api_url == '/wiki/cf/rest/api/content?title=A+parent+title&spaceKey=SPACE&expand=version':
+ result = ServerResponse(PAGE_INFO_RESPONSE)
+ elif api_url == '/wiki/cf/rest/api/content?title=A+new+page+title&spaceKey=SPACE&expand=version':
+ result = ServerResponse(PAGE_INFO_RESPONSE)
+ else:
+ raise Exception(f"Unknown route: {api_url}")
+ return result
+
+ def requests_post(self, api_url, json=None):
+ result = ServerResponse("null")
+ if api_url == "/wiki/cf/rest/api/content":
+ self.page_created = True
+ result = ServerResponse(CREATE_PAGE_RESPONSE)
+ else:
+ raise Exception(f"Unknown route: {api_url}")
+ return result
+
+ def requests_put(self, api_url, json=None):
+ result = ServerResponse("null")
+ if api_url == '/wiki/cf/rest/api/content/1234':
+ result = ServerResponse(UPDATE_PAGE_RESPONSE)
+ else:
+ raise Exception(f"Unknown route: {api_url}")
+ return result
+
+
+PAGE_INFO_RESPONSE = '''
+{
+ "results": [
+ {
+ "id": "1234",
+ "type": "page",
+ "status": "current",
+ "title": "A page title",
+ "version": {
+ "by": {
+ "type": "known",
+ "username": "testuser",
+ "userKey": "2c9239b948dc82440148dc876925181a",
+ "profilePicture": {
+ "path": "/wiki/cf/images/icons/profilepics/default.svg",
+ "width": 48,
+ "height": 48,
+ "isDefault": true
+ },
+ "displayName": "Test User",
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc876925181a"
+ },
+ "_expandable": {
+ "status": ""
+ }
+ },
+ "when": "2020-10-23T16:54:50.000Z",
+ "message": "",
+ "number": 3,
+ "minorEdit": false,
+ "hidden": false,
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/experimental/content/1234/version/3"
+ },
+ "_expandable": {
+ "content": "/rest/api/content/1234"
+ }
+ },
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/A+page+title",
+ "edit": "/pages/resumedraft.action?draftId=1234&draftShareId=0b59bcea-e6ea-44cc-a0b1-745f7d9e441d",
+ "tinyui": "/x/chcmFw",
+ "self": "https://testcontext/wiki/cf/rest/api/content/1234"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/1234/child",
+ "restrictions": "/rest/api/content/1234/restriction/byOperation",
+ "history": "/rest/api/content/1234/history",
+ "ancestors": "",
+ "body": "",
+ "descendants": "/rest/api/content/1234/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ }
+ ],
+ "start": 0,
+ "limit": 25,
+ "size": 1,
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/content?spaceKey=SPACE&expand=version&title=A%20page%20title",
+ "base": "https://testcontext/wiki/cf",
+ "context": "/wiki/cf"
+ }
+}
+'''
+
+NO_PAGE_INFO_RESPONSE = '''
+{
+ "results": [],
+ "start": 0,
+ "limit": 25,
+ "size": 0,
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/content?spaceKey=SPACE&expand=ancestors&title=A%20new%20page%20title",
+ "base": "https://testcontext/wiki/cf",
+ "context": "/wiki/cf"
+ }
+}
+'''
+
+PAGE_INFO_w_ANCESTORS_RESPONSE = '''
+{
+ "results": [
+ {
+ "id": "388386405",
+ "type": "page",
+ "status": "current",
+ "title": "A new page title",
+ "ancestors": [
+ {
+ "id": "119239646",
+ "type": "page",
+ "status": "current",
+ "title": "Space Home",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Space+Home",
+ "edit": "/pages/resumedraft.action?draftId=119239646",
+ "tinyui": "/x/3nMbBw",
+ "self": "https://testcontext/wiki/cf/rest/api/content/119239646"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/119239646/child",
+ "restrictions": "/rest/api/content/119239646/restriction/byOperation",
+ "history": "/rest/api/content/119239646/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/119239646/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "148348821",
+ "type": "page",
+ "status": "current",
+ "title": "Project SPACE",
+ "extensions": {
+ "position": 85
+ },
+ "_links": {
+ "webui": "/display/SPACE/Project+SPACE",
+ "edit": "/pages/resumedraft.action?draftId=148348821",
+ "tinyui": "/x/lZ-XC",
+ "self": "https://testcontext/wiki/cf/rest/api/content/148348821"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/148348821/child",
+ "restrictions": "/rest/api/content/148348821/restriction/byOperation",
+ "history": "/rest/api/content/148348821/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/148348821/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "148348824",
+ "type": "page",
+ "status": "current",
+ "title": "Forthic",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Forthic",
+ "edit": "/pages/resumedraft.action?draftId=148348824",
+ "tinyui": "/x/mJ-XC",
+ "self": "https://testcontext/wiki/cf/rest/api/content/148348824"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/148348824/child",
+ "restrictions": "/rest/api/content/148348824/restriction/byOperation",
+ "history": "/rest/api/content/148348824/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/148348824/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "248042769",
+ "type": "page",
+ "status": "current",
+ "title": "Forthic Framework",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Forthic+Framework",
+ "edit": "/pages/resumedraft.action?draftId=248042769&draftShareId=e6dfb6e9-9a98-4e20-8afc-8fdfaa354ace",
+ "tinyui": "/x/EdXIDg",
+ "self": "https://testcontext/wiki/cf/rest/api/content/248042769"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/248042769/child",
+ "restrictions": "/rest/api/content/248042769/restriction/byOperation",
+ "history": "/rest/api/content/248042769/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/248042769/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "261397943",
+ "type": "page",
+ "status": "current",
+ "title": "A parent title",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Forthic+Testing",
+ "edit": "/pages/resumedraft.action?draftId=261397943&draftShareId=5ebe725d-0d69-46a5-bf3f-5cd01d7c17c7",
+ "tinyui": "/x/t52UDw",
+ "self": "https://testcontext/wiki/cf/rest/api/content/261397943"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/261397943/child",
+ "restrictions": "/rest/api/content/261397943/restriction/byOperation",
+ "history": "/rest/api/content/261397943/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/261397943/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ }
+ ],
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/A+new+page+title",
+ "edit": "/pages/resumedraft.action?draftId=388386405",
+ "tinyui": "/x/ZU4mFw",
+ "self": "https://testcontext/wiki/cf/rest/api/content/388386405"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/388386405/child",
+ "restrictions": "/rest/api/content/388386405/restriction/byOperation",
+ "history": "/rest/api/content/388386405/history",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/388386405/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ }
+ ],
+ "start": 0,
+ "limit": 25,
+ "size": 1,
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/content?spaceKey=SPACE&expand=ancestors&title=A%20new%20page%20title",
+ "base": "https://testcontext/wiki/cf",
+ "context": "/wiki/cf"
+ }
+}
+'''
+
+
+CREATE_PAGE_RESPONSE = '''
+{
+ "id": "388386403",
+ "type": "page",
+ "status": "current",
+ "title": "A new page title",
+ "space": {
+ "id": 119963668,
+ "key": "SPACE",
+ "name": "Space",
+ "type": "global",
+ "_links": {
+ "webui": "/display/SPACE",
+ "self": "https://testcontext/wiki/cf/rest/api/space/SPACE"
+ },
+ "_expandable": {
+ "metadata": "",
+ "icon": "",
+ "description": "",
+ "homepage": "/rest/api/content/119239646"
+ }
+ },
+ "history": {
+ "latest": true,
+ "createdBy": {
+ "type": "known",
+ "username": "SPACE-auto",
+ "userKey": "2c9239b948dc82440148dc875dc709a1",
+ "profilePicture": {
+ "path": "/wiki/cf/images/icons/profilepics/default.svg",
+ "width": 48,
+ "height": 48,
+ "isDefault": true
+ },
+ "displayName": "SPACE-auto",
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc875dc709a1"
+ },
+ "_expandable": {
+ "status": ""
+ }
+ },
+ "createdDate": "2020-10-30T15:48:59.311Z",
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/content/388386403/history"
+ },
+ "_expandable": {
+ "lastUpdated": "",
+ "previousVersion": "",
+ "contributors": "",
+ "nextVersion": ""
+ }
+ },
+ "version": {
+ "by": {
+ "type": "known",
+ "username": "SPACE-auto",
+ "userKey": "2c9239b948dc82440148dc875dc709a1",
+ "profilePicture": {
+ "path": "/wiki/cf/images/icons/profilepics/default.svg",
+ "width": 48,
+ "height": 48,
+ "isDefault": true
+ },
+ "displayName": "SPACE-auto",
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc875dc709a1"
+ },
+ "_expandable": {
+ "status": ""
+ }
+ },
+ "when": "2020-10-30T15:48:59.311Z",
+ "message": "",
+ "number": 1,
+ "minorEdit": false,
+ "hidden": false,
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/experimental/content/388386403/version/1"
+ },
+ "_expandable": {
+ "content": "/rest/api/content/388386403"
+ }
+ },
+ "ancestors": [
+ {
+ "id": "119239646",
+ "type": "page",
+ "status": "current",
+ "title": "Space Home",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Space+Home",
+ "edit": "/pages/resumedraft.action?draftId=119239646",
+ "tinyui": "/x/3nMbBw",
+ "self": "https://testcontext/wiki/cf/rest/api/content/119239646"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/119239646/child",
+ "restrictions": "/rest/api/content/119239646/restriction/byOperation",
+ "history": "/rest/api/content/119239646/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/119239646/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "148348821",
+ "type": "page",
+ "status": "current",
+ "title": "Project SPACE",
+ "extensions": {
+ "position": 85
+ },
+ "_links": {
+ "webui": "/display/SPACE/Project+SPACE",
+ "edit": "/pages/resumedraft.action?draftId=148348821",
+ "tinyui": "/x/lZ-XC",
+ "self": "https://testcontext/wiki/cf/rest/api/content/148348821"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/148348821/child",
+ "restrictions": "/rest/api/content/148348821/restriction/byOperation",
+ "history": "/rest/api/content/148348821/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/148348821/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "148348824",
+ "type": "page",
+ "status": "current",
+ "title": "Forthic",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Forthic",
+ "edit": "/pages/resumedraft.action?draftId=148348824",
+ "tinyui": "/x/mJ-XC",
+ "self": "https://testcontext/wiki/cf/rest/api/content/148348824"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/148348824/child",
+ "restrictions": "/rest/api/content/148348824/restriction/byOperation",
+ "history": "/rest/api/content/148348824/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/148348824/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "248042769",
+ "type": "page",
+ "status": "current",
+ "title": "Forthic Framework",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Forthic+Framework",
+ "edit": "/pages/resumedraft.action?draftId=248042769&draftShareId=e6dfb6e9-9a98-4e20-8afc-8fdfaa354ace",
+ "tinyui": "/x/EdXIDg",
+ "self": "https://testcontext/wiki/cf/rest/api/content/248042769"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/248042769/child",
+ "restrictions": "/rest/api/content/248042769/restriction/byOperation",
+ "history": "/rest/api/content/248042769/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/248042769/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "261397943",
+ "type": "page",
+ "status": "current",
+ "title": "A parent title",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Forthic+Testing",
+ "edit": "/pages/resumedraft.action?draftId=261397943&draftShareId=5ebe725d-0d69-46a5-bf3f-5cd01d7c17c7",
+ "tinyui": "/x/t52UDw",
+ "self": "https://testcontext/wiki/cf/rest/api/content/261397943"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/261397943/child",
+ "restrictions": "/rest/api/content/261397943/restriction/byOperation",
+ "history": "/rest/api/content/261397943/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/261397943/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ }
+ ],
+ "container": {
+ "id": 119963668,
+ "key": "SPACE",
+ "name": "Space",
+ "type": "global",
+ "_links": {
+ "webui": "/display/SPACE",
+ "self": "https://testcontext/wiki/cf/rest/api/space/SPACE"
+ },
+ "_expandable": {
+ "metadata": "",
+ "icon": "",
+ "description": "",
+ "homepage": "/rest/api/content/119239646"
+ }
+ },
+ "body": {
+ "storage": {
+ "value": "This is a test
",
+ "representation": "storage",
+ "_expandable": {
+ "content": "/rest/api/content/388386403"
+ }
+ },
+ "_expandable": {
+ "editor": "",
+ "view": "",
+ "export_view": "",
+ "styled_view": "",
+ "anonymous_export_view": ""
+ }
+ },
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/A+new+page+title",
+ "edit": "/pages/resumedraft.action?draftId=388386403",
+ "tinyui": "/x/Y04mFw",
+ "collection": "/rest/api/content",
+ "base": "https://testcontext/wiki/cf",
+ "context": "/wiki/cf",
+ "self": "https://testcontext/wiki/cf/rest/api/content/388386403"
+ },
+ "_expandable": {
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/388386403/child",
+ "restrictions": "/rest/api/content/388386403/restriction/byOperation",
+ "descendants": "/rest/api/content/388386403/descendant"
+ }
+}
+'''
+
+UPDATE_PAGE_RESPONSE = '''
+{
+ "id": "1234",
+ "type": "page",
+ "status": "current",
+ "title": "A new page title",
+ "space": {
+ "id": 119963668,
+ "key": "SPACE",
+ "name": "SPACE",
+ "type": "global",
+ "_links": {
+ "webui": "/display/SPACE",
+ "self": "https://testcontext/wiki/cf/rest/api/space/SPACE"
+ },
+ "_expandable": {
+ "metadata": "",
+ "icon": "",
+ "description": "",
+ "homepage": "/rest/api/content/119239646"
+ }
+ },
+ "history": {
+ "latest": true,
+ "createdBy": {
+ "type": "known",
+ "username": "SPACE-auto",
+ "userKey": "2c9239b948dc82440148dc875dc709a1",
+ "profilePicture": {
+ "path": "/wiki/cf/images/icons/profilepics/default.svg",
+ "width": 48,
+ "height": 48,
+ "isDefault": true
+ },
+ "displayName": "SPACE-auto",
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc875dc709a1"
+ },
+ "_expandable": {
+ "status": ""
+ }
+ },
+ "createdDate": "2020-10-30T15:58:05.590Z",
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/content/388386405/history"
+ },
+ "_expandable": {
+ "lastUpdated": "",
+ "previousVersion": "",
+ "contributors": "",
+ "nextVersion": ""
+ }
+ },
+ "version": {
+ "by": {
+ "type": "known",
+ "username": "SPACE-auto",
+ "userKey": "2c9239b948dc82440148dc875dc709a1",
+ "profilePicture": {
+ "path": "/wiki/cf/images/icons/profilepics/default.svg",
+ "width": 48,
+ "height": 48,
+ "isDefault": true
+ },
+ "displayName": "SPACE-auto",
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/api/user?key=2c9239b948dc82440148dc875dc709a1"
+ },
+ "_expandable": {
+ "status": ""
+ }
+ },
+ "when": "2020-10-30T16:29:18.318Z",
+ "number": 2,
+ "minorEdit": false,
+ "hidden": false,
+ "_links": {
+ "self": "https://testcontext/wiki/cf/rest/experimental/content/388386405/version/2"
+ },
+ "_expandable": {
+ "content": "/rest/api/content/388386405"
+ }
+ },
+ "ancestors": [
+ {
+ "id": "119239646",
+ "type": "page",
+ "status": "current",
+ "title": "SPACE Home",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/SPACE+Home",
+ "edit": "/pages/resumedraft.action?draftId=119239646",
+ "tinyui": "/x/3nMbBw",
+ "self": "https://testcontext/wiki/cf/rest/api/content/119239646"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/119239646/child",
+ "restrictions": "/rest/api/content/119239646/restriction/byOperation",
+ "history": "/rest/api/content/119239646/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/119239646/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "148348821",
+ "type": "page",
+ "status": "current",
+ "title": "Project SPACE",
+ "extensions": {
+ "position": 85
+ },
+ "_links": {
+ "webui": "/display/SPACE/Project+SPACE",
+ "edit": "/pages/resumedraft.action?draftId=148348821",
+ "tinyui": "/x/lZ-XC",
+ "self": "https://testcontext/wiki/cf/rest/api/content/148348821"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/148348821/child",
+ "restrictions": "/rest/api/content/148348821/restriction/byOperation",
+ "history": "/rest/api/content/148348821/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/148348821/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "148348824",
+ "type": "page",
+ "status": "current",
+ "title": "Forthic",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Forthic",
+ "edit": "/pages/resumedraft.action?draftId=148348824",
+ "tinyui": "/x/mJ-XC",
+ "self": "https://testcontext/wiki/cf/rest/api/content/148348824"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/148348824/child",
+ "restrictions": "/rest/api/content/148348824/restriction/byOperation",
+ "history": "/rest/api/content/148348824/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/148348824/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "248042769",
+ "type": "page",
+ "status": "current",
+ "title": "Forthic Framework",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Forthic+Framework",
+ "edit": "/pages/resumedraft.action?draftId=248042769&draftShareId=e6dfb6e9-9a98-4e20-8afc-8fdfaa354ace",
+ "tinyui": "/x/EdXIDg",
+ "self": "https://testcontext/wiki/cf/rest/api/content/248042769"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/248042769/child",
+ "restrictions": "/rest/api/content/248042769/restriction/byOperation",
+ "history": "/rest/api/content/248042769/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/248042769/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ },
+ {
+ "id": "261397943",
+ "type": "page",
+ "status": "current",
+ "title": "Forthic Testing",
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/Forthic+Testing",
+ "edit": "/pages/resumedraft.action?draftId=261397943&draftShareId=5ebe725d-0d69-46a5-bf3f-5cd01d7c17c7",
+ "tinyui": "/x/t52UDw",
+ "self": "https://testcontext/wiki/cf/rest/api/content/261397943"
+ },
+ "_expandable": {
+ "container": "/rest/api/space/SPACE",
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/261397943/child",
+ "restrictions": "/rest/api/content/261397943/restriction/byOperation",
+ "history": "/rest/api/content/261397943/history",
+ "ancestors": "",
+ "body": "",
+ "version": "",
+ "descendants": "/rest/api/content/261397943/descendant",
+ "space": "/rest/api/space/SPACE"
+ }
+ }
+ ],
+ "container": {
+ "id": 119963668,
+ "key": "SPACE",
+ "name": "SPACE",
+ "type": "global",
+ "_links": {
+ "webui": "/display/SPACE",
+ "self": "https://testcontext/wiki/cf/rest/api/space/SPACE"
+ },
+ "_expandable": {
+ "metadata": "",
+ "icon": "",
+ "description": "",
+ "homepage": "/rest/api/content/119239646"
+ }
+ },
+ "body": {
+ "storage": {
+ "value": "This is second a test
",
+ "representation": "storage",
+ "_expandable": {
+ "content": "/rest/api/content/388386405"
+ }
+ },
+ "_expandable": {
+ "editor": "",
+ "view": "",
+ "export_view": "",
+ "styled_view": "",
+ "anonymous_export_view": ""
+ }
+ },
+ "extensions": {
+ "position": "none"
+ },
+ "_links": {
+ "webui": "/display/SPACE/A+new+page+title",
+ "edit": "/pages/resumedraft.action?draftId=388386405",
+ "tinyui": "/x/ZU4mFw",
+ "collection": "/rest/api/content",
+ "base": "https://testcontext/wiki/cf",
+ "context": "/wiki/cf",
+ "self": "https://testcontext/wiki/cf/rest/api/content/388386405"
+ },
+ "_expandable": {
+ "metadata": "",
+ "operations": "",
+ "children": "/rest/api/content/388386405/child",
+ "restrictions": "/rest/api/content/388386405/restriction/byOperation",
+ "descendants": "/rest/api/content/388386405/descendant"
+ }
+}
'''
\ No newline at end of file
diff --git a/tests/tests_py/modules/jira_context.py b/tests/tests_py/modules/jira_context.py
index d39b363..cea54fc 100644
--- a/tests/tests_py/modules/jira_context.py
+++ b/tests/tests_py/modules/jira_context.py
@@ -1,19 +1,19 @@
import json
from forthic.modules.jira_module import JiraContext
+
class ServerResponse:
def __init__(self, string, status_code=200):
self.json_string = string
self.status_code = status_code
self.text = ""
self.ok = status_code < 300
-
+
def json(self):
result = json.loads(self.json_string)
return result
-
class JiraTestContext(JiraContext):
def get_host(self):
return "http://testcontext"
@@ -55,14 +55,22 @@ def requests_put(self, api_url, json=None, session=None):
REST_API_2_FIELD_RESPONSE = '''
-[{"id":"issuekey","name":"Key","custom":false,"orderable":false,"navigable":true,"searchable":false,"clauseNames":["id","issue","issuekey","key"]},
-{"id":"assignee","name":"Assignee","custom":false,"orderable":true,"navigable":true,"searchable":true,"clauseNames":["assignee"],"schema":{"type":"user","system":"assignee"}},
-{"id":"summary","name":"Summary","custom":false,"orderable":true,"navigable":true,"searchable":true,"clauseNames":["summary"],"schema":{"type":"string","system":"summary"}},
-{"id":"project","name":"Project","custom":false,"orderable":false,"navigable":true,"searchable":true,"clauseNames":["project"],"schema":{"type":"project","system":"project"}},
-{"id":"reporter","name":"Reporter","custom":false,"orderable":true,"navigable":true,"searchable":true,"clauseNames":["reporter"],"schema":{"type":"user","system":"reporter"}},
-{"id":"issuetype","name":"Issue Type","custom":false,"orderable":true,"navigable":true,"searchable":true,"clauseNames":["issuetype","type"],"schema":{"type":"issuetype","system":"issuetype"}},
-{"id":"customfield_10460","name":"Risk_Factor","custom":true,"orderable":true,"navigable":true,"searchable":true,"clauseNames":["cf[10460]","Risk_Factor"],"schema":{"type":"option","custom":"com.atlassian.jira.plugin.system.customfieldtypes:select","customId":10460}},
-{"id":"timespent","name":"Time Spent","custom":false,"orderable":false,"navigable":true,"searchable":false,"clauseNames":["timespent"],"schema":{"type":"number","system":"timespent"}}]
+[{"id":"issuekey","name":"Key","custom":false,"orderable":false,"navigable":true,"searchable":false,
+"clauseNames":["id","issue","issuekey","key"]},
+{"id":"assignee","name":"Assignee","custom":false,"orderable":true,"navigable":true,"searchable":true,
+"clauseNames":["assignee"],"schema":{"type":"user","system":"assignee"}},
+{"id":"summary","name":"Summary","custom":false,"orderable":true,"navigable":true,"searchable":true,
+"clauseNames":["summary"],"schema":{"type":"string","system":"summary"}},
+{"id":"project","name":"Project","custom":false,"orderable":false,"navigable":true,"searchable":true,
+"clauseNames":["project"],"schema":{"type":"project","system":"project"}},
+{"id":"reporter","name":"Reporter","custom":false,"orderable":true,"navigable":true,"searchable":true,
+"clauseNames":["reporter"],"schema":{"type":"user","system":"reporter"}},
+{"id":"issuetype","name":"Issue Type","custom":false,"orderable":true,"navigable":true,"searchable":true,
+"clauseNames":["issuetype","type"],"schema":{"type":"issuetype","system":"issuetype"}},
+{"id":"customfield_10460","name":"Risk_Factor","custom":true,"orderable":true,"navigable":true,"searchable":true,
+"clauseNames":["cf[10460]","Risk_Factor"],"schema":{"type":"option","custom":"com.atlassian.jira.plugin.system.customfieldtypes:select","customId":10460}},
+{"id":"timespent","name":"Time Spent","custom":false,"orderable":false,"navigable":true,"searchable":false,
+"clauseNames":["timespent"],"schema":{"type":"number","system":"timespent"}}]
'''
SEARCH_RESPONSE1 = '''
diff --git a/tests/tests_py/modules/test_confluence_module.py b/tests/tests_py/modules/test_confluence_module.py
index 5ed2290..d3389a5 100644
--- a/tests/tests_py/modules/test_confluence_module.py
+++ b/tests/tests_py/modules/test_confluence_module.py
@@ -48,10 +48,11 @@ def test_UPSERT_PAGE(self):
""")
def test_pipe_ESCAPE_TABLE_CONTENT2(self):
- self.interp.run("""
+ self.interp.run("""
'+*Q2 Objectives*+\r\n\r\nReduce tech debts, operational burdens and cost-to-serve' |ESCAPE-TABLE-CONTENT
""")
assert(self.interp.stack[0] == '+*Q2 Objectives*+\nReduce tech debts, operational burdens and cost-to-serve')
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/tests_py/modules/test_html_module.py b/tests/tests_py/modules/test_html_module.py
index 6a0c770..d962dda 100644
--- a/tests/tests_py/modules/test_html_module.py
+++ b/tests/tests_py/modules/test_html_module.py
@@ -9,6 +9,7 @@ def get_interp():
result.run('[["html" ""]] USE-MODULES')
return result
+
class TestHtmlModule(unittest.TestCase):
def setUp(self):
self.interp = get_interp()
@@ -45,7 +46,7 @@ def test_child_nodes(self):
row @ CHILD-NODES LENGTH
""")
stack = self.interp.stack
- self.assertEqual([1, True, 3], self.interp.stack)
+ self.assertEqual([1, True, 3], stack)
def test_node_content(self):
self.interp.run("""
diff --git a/tests/tests_py/modules/test_jira_module.py b/tests/tests_py/modules/test_jira_module.py
index ed5e5f4..e750022 100644
--- a/tests/tests_py/modules/test_jira_module.py
+++ b/tests/tests_py/modules/test_jira_module.py
@@ -128,8 +128,10 @@ def test_FIELD_AS_OF_SINCE(self):
# NOTE: Here is the changelog
# [{'date': datetime.datetime(2020, 7, 25, 1, 36, 24, tzinfo=tzutc()), 'field': 'Risk_Factor', 'from': '', 'to': 'Blue'},
- # {'date': datetime.datetime(2020, 7, 25, 1, 38, 46, tzinfo=tzutc()), 'field': 'Risk_Factor', 'from': 'Blue', 'to': 'Green', 'from_': '32078', 'to_': '32075'},
- # {'date': datetime.datetime(2020, 8, 15, 1, 39, 5, tzinfo=tzutc()), 'field': 'Risk_Factor', 'from': 'Green', 'to': 'Yellow', 'from_': '32078', 'to_': '32075'}]
+ # {'date': datetime.datetime(2020, 7, 25, 1, 38, 46, tzinfo=tzutc()), 'field': 'Risk_Factor',
+ # 'from': 'Blue', 'to': 'Green', 'from_': '32078', 'to_': '32075'},
+ # {'date': datetime.datetime(2020, 8, 15, 1, 39, 5, tzinfo=tzutc()), 'field': 'Risk_Factor',
+ # 'from': 'Green', 'to': 'Yellow', 'from_': '32078', 'to_': '32075'}]
2020-07-25 changes @ "Risk_Factor" 2020-07-01 jira.FIELD-AS-OF-SINCE
2020-10-01 changes @ "Risk_Factor" 2020-07-01 jira.FIELD-AS-OF-SINCE
diff --git a/tests/tests_py/modules/test_org_module.py b/tests/tests_py/modules/test_org_module.py
index 7b80af6..7a185e0 100644
--- a/tests/tests_py/modules/test_org_module.py
+++ b/tests/tests_py/modules/test_org_module.py
@@ -38,11 +38,9 @@ def test_GROUP_BY_LEADS(self):
items = [
{"key": 101, "owner": "user101"},
{"key": 102, "owner": "user102"},
-
{"key": 202, "owner": "user202"},
{"key": 203, "owner": "user203"},
{"key": 302, "owner": "mgr2"},
-
{"key": 401, "owner": "user401"},
]
@@ -87,6 +85,7 @@ def test_CHAIN_KEY_FUNC(self):
self.interp.run("['user101' 'mgr1' 'user203' 'director1'] 'vp1' org.CHAIN-KEY-FUNC SORT-w/KEY-FUNC")
self.assertEqual(['director1', 'mgr1', 'user101', 'user203'], self.interp.stack[0])
+
def get_context():
def get_users_managers():
res = [
@@ -96,8 +95,8 @@ def get_users_managers():
["user201", "mgr2"],
["user202", "mgr2"],
["user203", "mgr2"],
- ["mgr1", "director1"],
- ["mgr2", "director1"],
+ ["mgr1", "director1"],
+ ["mgr2", "director1"],
["director1", "vp1"]
]
return res
diff --git a/tests/tests_py/test_global_module.py b/tests/tests_py/test_global_module.py
index 4cb4ca7..c6ecd69 100644
--- a/tests/tests_py/test_global_module.py
+++ b/tests/tests_py/test_global_module.py
@@ -1,4 +1,3 @@
-from operator import index
import unittest
import datetime
import pytz
@@ -6,6 +5,7 @@
from forthic.tokenizer import DLE
from forthic.global_module import GlobalModuleError
+
class TestGlobalModule(unittest.TestCase):
def test_literal(self):
interp = Interpreter()
@@ -114,11 +114,11 @@ def test_memo(self):
self.assertEqual(interp.stack[-1], 1)
interp.run("COUNT! COUNT")
- self.assertEqual(interp.stack[-1] , 2)
+ self.assertEqual(interp.stack[-1], 2)
self.assertEqual(len(interp.stack), 3)
interp.run("COUNT!@")
- self.assertEqual(interp.stack[-1] , 3)
+ self.assertEqual(interp.stack[-1], 3)
def test_rec(self):
interp = Interpreter()
@@ -139,7 +139,7 @@ def test_rec_at(self):
'beta' REC@
""")
self.assertEqual(len(interp.stack), 1)
- self.assertEqual(interp.stack[0] , 3)
+ self.assertEqual(interp.stack[0], 3)
def test_l_rec_bang(self):
# Case: Set value on a record
@@ -242,7 +242,6 @@ def test_reverse(self):
self.assertEqual(len(interp.stack), 1)
self.assertEqual(list(interp.stack[-1].keys()), ["b", "a"])
-
def test_unique(self):
interp = Interpreter()
interp.run("""
@@ -777,7 +776,6 @@ def test_UNION(self):
self.assertEqual(sorted(list(stack[0].keys())), ['a', 'b', 'c', 'd', 'f'])
self.assertEqual(sorted(list(stack[0].values())), [1, 2, 3, 10, 40])
-
def test_select(self):
interp = Interpreter()
interp.run("""
@@ -1134,7 +1132,6 @@ def test_pipe_ascii(self):
stack = interp.stack
self.assertEqual(stack[0], "HOWDY, Everyone!")
-
def test_strip(self):
interp = Interpreter()
interp.run("""
@@ -1199,7 +1196,6 @@ def test_URL_DECODE(self):
stack = interp.stack
self.assertEqual(stack[0], "now/is the time")
-
def test_default(self):
interp = Interpreter()
interp.run("""
diff --git a/tests/tests_py/test_interpreter.py b/tests/tests_py/test_interpreter.py
index 2ad4a89..7f4bf66 100644
--- a/tests/tests_py/test_interpreter.py
+++ b/tests/tests_py/test_interpreter.py
@@ -4,6 +4,7 @@
from forthic.module import Module, ModuleWord
from tests.tests_py.sample_date_module import SampleDateModule
+
class TestInterpreter(unittest.TestCase):
def test_initial_state(self):
@@ -11,26 +12,22 @@ def test_initial_state(self):
self.assertEqual(0, len(interp.stack))
self.assertEqual("", interp.module_stack[0].name)
-
def test_push_string(self):
interp = Interpreter()
interp.run("'Howdy'")
self.assertEqual("Howdy", interp.stack[0])
-
def test_comment(self):
interp = Interpreter()
interp.run("# A comment")
interp.run("#A comment")
self.assertEqual(0, len(interp.stack))
-
def test_empty_array(self):
interp = Interpreter()
interp.run("[]")
self.assertEqual([], interp.stack[0])
-
def test_start_module(self):
interp = Interpreter()
@@ -62,7 +59,6 @@ def test_start_module(self):
self.assertEqual(1, len(interp.module_stack))
self.assertEqual(interp.module_stack[0], interp.app_module)
-
def test_definition(self):
# Can define and find a word in the app module
interp = Interpreter()
@@ -162,7 +158,6 @@ def test_search_global_module(self):
return False
return True
-
def test_use_module(self):
interp = Interpreter()
interp.register_module(SampleDateModule)
diff --git a/tests/tests_py/test_tokenizer.py b/tests/tests_py/test_tokenizer.py
index a535e1f..f47255f 100644
--- a/tests/tests_py/test_tokenizer.py
+++ b/tests/tests_py/test_tokenizer.py
@@ -3,6 +3,7 @@
from forthic.tokens import StringToken, StartArrayToken, EndArrayToken, StartModuleToken,\
EndModuleToken, StartDefinitionToken, EndDefinitionToken, StartMemoToken, WordToken, EOSToken
+
def get_tokens(tokenizer):
result = []
token = None
@@ -60,7 +61,6 @@ def test_end_definition(self):
self.assertIsInstance(tokens[1], EndDefinitionToken)
self.assertTrue(is_word_token(tokens[2], "WORD2"))
-
def test_start_module(self):
tokenizer = Tokenizer("{ {my-mod")
tokens = get_tokens(tokenizer)
diff --git a/tests/tests_py/test_tokenizer_errors.py b/tests/tests_py/test_tokenizer_errors.py
index 11c45e0..f430117 100644
--- a/tests/tests_py/test_tokenizer_errors.py
+++ b/tests/tests_py/test_tokenizer_errors.py
@@ -1,6 +1,7 @@
import unittest
from forthic.tokenizer import Tokenizer, UnterminatedStringError, InvalidDefinitionError
+
class TestTokenizerErrors(unittest.TestCase):
def test_unterminated_string(self):
"""Raise exception if strings are unterminated
@@ -8,14 +9,12 @@ def test_unterminated_string(self):
tokenizer = Tokenizer("'Unterminated")
self.assertRaises(UnterminatedStringError, tokenizer.next_token)
-
def test_start_definition_eos(self):
"""Can't have an empty definition
"""
tokenizer = Tokenizer(":")
self.assertRaises(InvalidDefinitionError, tokenizer.next_token)
-
def test_start_definition_special_chars(self):
"""Can't have definition with Forthic special chars
"""