1 | #!/usr/bin/python3 |
---|
2 | from fileinput import filename |
---|
3 | |
---|
4 | |
---|
5 | try: |
---|
6 | import unittest2 as unittest #for Python <= 2.6 |
---|
7 | except: |
---|
8 | import unittest |
---|
9 | |
---|
10 | import os |
---|
11 | import sys |
---|
12 | sys.path.append(os.path.dirname(sys.argv[0]) + '/') #Path to my unitTest directory |
---|
13 | from gluon import * |
---|
14 | |
---|
15 | from baseTest import BaseTest |
---|
16 | |
---|
17 | APP =sys.argv[1] |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | #This line executes your controller file, bringing all of the function declarations into the local namespace. |
---|
22 | #execfile("applications/" + APP + "/controllers/default.py", globals()) |
---|
23 | filename = "applications/" + APP + "/controllers/connectPC.py" |
---|
24 | |
---|
25 | exec(compile(open(filename, "rb").read(), filename, 'exec'), globals()) |
---|
26 | |
---|
27 | import opengnsys |
---|
28 | |
---|
29 | class TestStatusClients(BaseTest): |
---|
30 | |
---|
31 | |
---|
32 | def testGetStatusClients(self): |
---|
33 | ou_id = '2' #eupt |
---|
34 | lab_id = '6' #informatica1 |
---|
35 | pc_id = '36' #eupti115 |
---|
36 | |
---|
37 | login_info = opengnsys.doLogin() |
---|
38 | opengnsys.setApiKey(login_info['apikey']) |
---|
39 | |
---|
40 | statusClients = opengnsys.getStatusClients(ou_id, lab_id) |
---|
41 | pc_from_statusClients = None |
---|
42 | for pc in statusClients: |
---|
43 | if pc["id"] == 36: |
---|
44 | pc_from_statusClients = pc |
---|
45 | |
---|
46 | |
---|
47 | pc_from_statusClient = opengnsys.getStatusCient(ou_id, lab_id, pc_id) |
---|
48 | |
---|
49 | self.assertEqual(pc_from_statusClient['status'], pc_from_statusClients['status']) |
---|
50 | |
---|
51 | |
---|
52 | suite = unittest.TestSuite() |
---|
53 | suite.addTest(unittest.makeSuite(TestStatusClients)) |
---|
54 | unittest.TextTestRunner(verbosity=2).run(suite) |
---|