コード例 #1
0
 def test_login_wrong_ID(self):
     '''输入错误的账号'''
     data = {"mobilephone": "185932980", "pwd": "123456"}
     res = HttpRequest().http_request(self.login_url, data, 'get')
     try:
         self.assertEqual('20111', res.json()['code'])
     except AssertionError as  e:
         print("test_login_wrong_ID's error is {}".format(e))
コード例 #2
0
 def test_recharge_negative(self):
     '''充值为负数'''
     data = {"mobilephone": "18593298080", "amount": "-1100"}
     res = HttpRequest().http_request(self.recharge_url, data, 'post', cookie=self.cookies)
     try:
         self.assertEqual('20117', res.json()['code'])
     except AssertionError as e:
         print("test_recharge_noMoney's error is {}".format(e))
         raise e
コード例 #3
0
 def test_recharge_noID(self):
     '''不输入账号'''
     data = {"mobilephone": "", "amount": "1100"}
     res = HttpRequest().http_request(self.recharge_url, data, 'post', cookie=self.cookies)
     try:
         self.assertEqual('10001', res.json()['code'])
     except AssertionError as e:
         print("test_recharge_normal's error is {}".format(e))
         raise e
コード例 #4
0
 def test_login_noID(self):
     '''不输入账号'''
     data = {"mobilephone": "", "pwd": "123456"}
     res = HttpRequest().http_request(self.login_url, data, 'get')
     try:
         self.assertEqual('20103', res.json()['code'])
     except AssertionError as  e:
         print("test_login_noID's error is {}".format(e))
         raise e
コード例 #5
0
 def test_login_normal(self):
     '''正常登录'''
     data = {"mobilephone": "18593298080", "pwd": "123456"}
     res = HttpRequest().http_request(self.login_url, data, 'get')
     if res.cookies:
         setattr(GetDate,'Cookie')
     try:
         self.assertEqual('10001',res.json()['code'])
     except AssertionError as  e:
         print("test_login_normal's error is {}".format(e))
         raise e
コード例 #6
0
ファイル: ognsys.py プロジェクト: javsanpar/OpenRLabs
class Ognsys:
    def __init__(self, db):
        self.db = db

        ognsys_globals.init(db)

        self.http_request = HttpRequest()

    # ---- Return a list of dictionaries {OU_ID: OU_NAME} ---
    def get_ous(self):
        self.http_request.set_connector(
            UsingPoolManagerConnector(ognsys_globals.local.__POOL_MANAGER__))
        return self.http_request.do_action(GetOUS())

    def set_apikey(self, ou_id):

        ou_credentials = ou.get_ou_credentials(self.db, ou_id)

        self.http_request.set_connector(
            UsingPoolManagerConnector(ognsys_globals.local.__POOL_MANAGER__))
        credentials = self.http_request.do_action(DoLogin(ou_credentials))

        if 'apikey' in credentials:
            ognsys_globals.set_apikey(credentials['apikey'])

            return True
        else:

            return False

    def synchronize_table_ous(self, db):
        ou = self.get_ous()
        adoDB_ous.update_ous_in_table(db, ou)
        adoDB_ous.delete_ous_not_in_ous_server(db, ou)

    def get_query_ous(self, db):
        return adoDB_ous.get_queryOUs(db)
コード例 #7
0
ファイル: ognsys.py プロジェクト: javsanpar/OpenRLabs
    def __init__(self, db):
        self.db = db

        ognsys_globals.init(db)

        self.http_request = HttpRequest()
コード例 #8
0
 def __init__(self, my_context):
     self.context = my_context
     
     self.http_request = HttpRequest()
コード例 #9
0
class Client:
    
    def __init__(self, my_context):
        self.context = my_context
        
        self.http_request = HttpRequest()
 
    
    def update_context(self, *args):
        if args:
            for arg in args:
                self.context.update(arg)
            
            
        
    # Meter este metodo en  objeto client_lab y pasarle pool manager.    
    def get_status_client(self):
        self.http_request.set_connector(NotUsingPoolManagerConnector())        
        return self.http_request.do_action(GetStatusClient(self.context.ip))
            


    def reserve_remote_pc(self):
        self.http_request.set_connector(UsingPoolManagerConnector(ognsys_globals.local.__POOL_MANAGER__))        
        return self.http_request.do_action(ReserveClient(self.context.ou_id,
                                                         self.context.image_id,
                                                         self.context.lab_id,
                                                         self.context.maxtime) )
                    
    def redirect_events(self):
        self.http_request.set_connector(UsingPoolManagerConnector(ognsys_globals.local.__POOL_MANAGER__))
        return self.http_request.do_action(RedirectEvents(self.context.ou_id, self.context.lab_id,
                                                          self.context.id, self.context.maxtime) )
                                                          
    def register_session_timeout(self):
        self.http_request.set_connector(UsingPoolManagerConnector(ognsys_globals.local.__POOL_MANAGER__))     
        return self.http_request.do_action(RegisterSessionTimeout(self.context.ou_id, self.context.lab_id, 
                                                                  self.context.id, self.context.maxtime) )

    
                                                        
        
    
    def __unreserve_remote_pc(self):
        self.http_request.set_connector(UsingPoolManagerConnector(ognsys_globals.local.__POOL_MANAGER__))     
        return self.http_request.do_action(UnreserveClient(self.context['ou_id'], self.context['lab_id'], self.context['pc_id']))
        
    
    def unreserve_remote_pc(self):
        
        self.remove_active_reserve()
        
        unreserve_ognsys = self.__unreserve_remote_pc()                
        
        return unreserve_ognsys
        
    def remove_active_reserve(self):

        adoDB_active_reserves.remove_by_pc_id(self.context.db, self.context.pc_id)
        return "ok"