1 | #!/usr/bin/python3 |
---|
2 | from fileinput import filename |
---|
3 | |
---|
4 | try: |
---|
5 | import unittest2 as unittest #for Python <= 2.6 |
---|
6 | except: |
---|
7 | import unittest |
---|
8 | |
---|
9 | import os |
---|
10 | import sys |
---|
11 | sys.path.append(os.path.dirname(sys.argv[0]) + '/') #Path to my unitTest directory |
---|
12 | from gluon import * |
---|
13 | |
---|
14 | from baseTest import BaseTest |
---|
15 | |
---|
16 | APP =sys.argv[1] |
---|
17 | |
---|
18 | |
---|
19 | #This line executes your controller file, bringing all of the function declarations into the local namespace. |
---|
20 | #execfile("applications/" + APP + "/controllers/default.py", globals()) |
---|
21 | filename = "applications/" + APP + "/controllers/default.py" |
---|
22 | |
---|
23 | exec(compile(open(filename, "rb").read(), filename, 'exec'), globals()) |
---|
24 | |
---|
25 | from gluon.storage import Storage |
---|
26 | |
---|
27 | import ognsys |
---|
28 | from lab import Lab |
---|
29 | from client_lab import Client |
---|
30 | import ou |
---|
31 | |
---|
32 | class OgActions(BaseTest): |
---|
33 | |
---|
34 | def d_test_diskcfg(self): |
---|
35 | opengnsys.init(db, "4") |
---|
36 | lab = Lab("4" , "17") |
---|
37 | response = lab.getDiskConfigClient(194) |
---|
38 | |
---|
39 | self.assertIsNot(len(response), 0) |
---|
40 | |
---|
41 | def d_test_get_status_cient(self): |
---|
42 | opengnsys.init(db, "4") |
---|
43 | lab = Lab("4" , "17") |
---|
44 | response = lab.getStatusClient({ 'ip' : '10.7.1.96'}) |
---|
45 | |
---|
46 | self.assertIsNot(len(response), 0) |
---|
47 | |
---|
48 | def test_get_credentials(self): |
---|
49 | opengnsys = ognsys.Ognsys(db) |
---|
50 | r = opengnsys.set_apikey(4) |
---|
51 | |
---|
52 | self.assertIsNot(r, False) |
---|
53 | |
---|
54 | def test_get_labs(self): |
---|
55 | opengnsys = ognsys.Ognsys(db) |
---|
56 | opengnsys.set_apikey(4) |
---|
57 | labs = ou.get_labs_on(4) |
---|
58 | |
---|
59 | self.assertIsNot(len(labs), 0) |
---|
60 | |
---|
61 | def test_get_clients(self): |
---|
62 | opengnsys = ognsys.Ognsys(db) |
---|
63 | opengnsys.set_apikey(4) |
---|
64 | lab = Lab("4" , "17") |
---|
65 | clients = lab.get_remote_clients() |
---|
66 | print(clients) |
---|
67 | self.assertIsNot(len(clients), 0) |
---|
68 | |
---|
69 | def test_reserve_client(self): |
---|
70 | opengnsys = ognsys.Ognsys(db) |
---|
71 | opengnsys.set_apikey(4) |
---|
72 | |
---|
73 | my_context = Storage({"ou_id" : 4, "lab_id" : 17, "image_id": 16, "maxtime" : 2}) |
---|
74 | |
---|
75 | client = Client(my_context) |
---|
76 | equipo_reservado = client.reserve_remote_pc() |
---|
77 | print(equipo_reservado) |
---|
78 | |
---|
79 | r = client.redirect_events() |
---|
80 | print(r) |
---|
81 | t = client.register_session_timeout() |
---|
82 | print(t) |
---|
83 | |
---|
84 | self.assertIsNot(equipo_reservado, "") |
---|
85 | |
---|
86 | suite = unittest.TestSuite() |
---|
87 | suite.addTest(unittest.makeSuite(OgActions)) |
---|
88 | unittest.TextTestRunner(verbosity=2).run(suite) |
---|