-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_collabora_cli.py
61 lines (51 loc) · 2.55 KB
/
test_collabora_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
""" Command line unit tests for the Sunet Drive Collabora servers
Author: Richard Freitag <freitag@sunet.se>
"""
import unittest
import requests
import json
import logging
import hashlib
import xmltodict
import yaml
import threading
import time
import sunetnextcloud
import os
g_requestTimeout=10
expectedResultsFile = 'expected.yaml'
testThreadRunning = False
logger = logging.getLogger(__name__)
logging.basicConfig(format = '%(asctime)s - %(module)s.%(funcName)s - %(levelname)s: %(message)s',
datefmt = '%Y-%m-%d %H:%M:%S', level = logging.INFO)
with open(expectedResultsFile, "r") as stream:
expectedResults=yaml.safe_load(stream)
class TestCollabora(unittest.TestCase):
def test_logger(self):
global logger
logger.info(f'TestID: {self._testMethodName}')
pass
def test_collabora_capabilities(self):
global logger
logger.info(f'TestID: {self._testMethodName}')
drv = sunetnextcloud.TestTarget()
numCollaboraNodes = expectedResults[drv.target]['collabora']['nodes']
logger.info(f'Collabora nodes: {numCollaboraNodes}')
for i in range(1,numCollaboraNodes+1):
url=drv.get_collabora_capabilities_url(i)
logger.info(f'Testing collabora server url: {url}')
r =requests.get(url, timeout=g_requestTimeout)
j = json.loads(r.text)
self.assertEqual(j['hasMobileSupport'], expectedResults[drv.target]['collabora']['capabilities']['hasMobileSupport'])
self.assertEqual(j['hasProxyPrefix'], expectedResults[drv.target]['collabora']['capabilities']['hasProxyPrefix'])
self.assertEqual(j['hasTemplateSaveAs'], expectedResults[drv.target]['collabora']['capabilities']['hasTemplateSaveAs'])
self.assertEqual(j['hasTemplateSource'], expectedResults[drv.target]['collabora']['capabilities']['hasTemplateSource'])
self.assertEqual(j['hasZoteroSupport'], expectedResults[drv.target]['collabora']['capabilities']['hasZoteroSupport'])
self.assertEqual(j['productName'], expectedResults[drv.target]['collabora']['capabilities']['productName'])
self.assertEqual(j['productVersion'], expectedResults[drv.target]['collabora']['capabilities']['productVersion'])
self.assertEqual(j['productVersionHash'], expectedResults[drv.target]['collabora']['capabilities']['productVersionHash'])
logger.info(f'Collabora capabilities tested')
if __name__ == '__main__':
import xmlrunner
# unittest.main()
unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))