source: OpenRLabs-Git/web2py/applications/rlabs/unitTest/disabledTest/test_og_actions.py

main
Last change on this file was 8406aaa, checked in by David Fuertes <dfuertes@…>, 4 years ago

arreglado gitignore

  • Property mode set to 100644
File size: 2.4 KB
Line 
1#!/usr/bin/python3
2from fileinput import filename
3
4try:
5    import unittest2 as unittest #for Python <= 2.6
6except:
7    import unittest   
8
9import os
10import sys
11sys.path.append(os.path.dirname(sys.argv[0]) + '/') #Path to my unitTest directory
12from gluon import *
13
14from baseTest import BaseTest
15
16APP =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())
21filename = "applications/" + APP + "/controllers/default.py"
22
23exec(compile(open(filename, "rb").read(), filename, 'exec'), globals())
24
25from gluon.storage import Storage
26
27import ognsys
28from lab import Lab
29from client_lab import Client
30import ou
31
32class 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       
86suite = unittest.TestSuite()
87suite.addTest(unittest.makeSuite(OgActions))
88unittest.TextTestRunner(verbosity=2).run(suite)
Note: See TracBrowser for help on using the repository browser.