-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·55 lines (39 loc) · 1.43 KB
/
test.py
File metadata and controls
executable file
·55 lines (39 loc) · 1.43 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import pgpxmlrpc
import unittest
import os.path as osp
if int (sys.version [0]) >= 3:
import xmlrpc.client as xmlrpclib
else:
import xmlrpclib
print (sys.version)
SERVICE_KEY = '00970D7538ABB8435BF8E6CEE040C8BCA068662E'
CLIENT_KEY = '5CDD1A70201C2844823AEF81BEFD3D1DB2B51C31'
CLIENT_PWD = '123321'
GPG_HOMEDIR = osp.join (osp.dirname (osp.abspath (__file__)), '__keyring__')
class Test (unittest.TestCase):
@classmethod
def setUpClass (cls):
cls.service = pgpxmlrpc.Service (
'http://testapi.cherrybase:8080/pgpxmlrpc',
SERVICE_KEY,
GPG_HOMEDIR,
CLIENT_KEY,
CLIENT_PWD
)
cls.meta = xmlrpclib.Server ('http://testapi.cherrybase:8080/pgpxmlrpc/meta', encoding = 'utf-8', allow_none = True)
def test_sum (self):
self.assertEqual (self.service.test.sum (10, 200), 210)
self.assertEqual (self.service.test.sum ('А', 'Б'), u'АБ')
def test_hello (self):
self.assertEqual (self.service.test.hello ('tester'), 'Hello tester')
def test_restypes (self):
self.assertIsInstance (self.service.test.restypes (), list)
def test_system (self):
self.assertIn ('test.hello', self.service.system.listMethods ())
def test_meta (self):
self.assertEqual (self.meta.meta.info ()['code'], 'testapi')
if __name__ == "__main__":
unittest.main ()