1 | #!/usr/bin/python3 |
---|
2 | import clients |
---|
3 | import opengnsys |
---|
4 | |
---|
5 | from fileinput import filename |
---|
6 | |
---|
7 | |
---|
8 | |
---|
9 | try: |
---|
10 | import unittest2 as unittest #for Python <= 2.6 |
---|
11 | except: |
---|
12 | import unittest |
---|
13 | |
---|
14 | import os |
---|
15 | import sys |
---|
16 | sys.path.append(os.path.dirname(sys.argv[0]) + '/') #Path to my unitTest directory |
---|
17 | from gluon import * |
---|
18 | |
---|
19 | from baseTest import BaseTest |
---|
20 | |
---|
21 | APP =sys.argv[1] |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | #This line executes your controller file, bringing all of the function declarations into the local namespace. |
---|
26 | #execfile("applications/" + APP + "/controllers/default.py", globals()) |
---|
27 | filename = "applications/" + APP + "/controllers/connectPC.py" |
---|
28 | |
---|
29 | exec(compile(open(filename, "rb").read(), filename, 'exec'), globals()) |
---|
30 | |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | class EventsTest(BaseTest): |
---|
35 | |
---|
36 | def testLoginEvent(self): |
---|
37 | opengnsys.setServers(db) |
---|
38 | opengnsys.setApiKey(opengnsys.doLogin(db, '2')['apikey']) |
---|
39 | |
---|
40 | parametros_sesion_registrados = clients.register_session_parameters('2', '2', '6', '2') |
---|
41 | |
---|
42 | print(parametros_sesion_registrados) |
---|
43 | |
---|
44 | #self.assertRegex(message['output'], "Sending") |
---|
45 | self.assertIsNotNone(parametros_sesion_registrados) |
---|
46 | |
---|
47 | def testLogoutEvent(self): |
---|
48 | opengnsys.setServers(db) |
---|
49 | opengnsys.setApiKey(opengnsys.doLogin(db, '2')['apikey']) |
---|
50 | |
---|
51 | resultad0 = clients.unreserveRemotePC('2', '2', '6') |
---|
52 | |
---|
53 | print(resultad0) |
---|
54 | |
---|
55 | #self.assertRegex(message['output'], "Sending") |
---|
56 | self.assertIsNotNone(resultad0) |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | suite = unittest.TestSuite() |
---|
61 | suite.addTest(unittest.makeSuite(EventsTest)) |
---|
62 | unittest.TextTestRunner(verbosity=2).run(suite) |
---|