Beispiel #1
0
 def test_0002(self):
     """
     Test GetSessionByID
     """
     ret = SessionHelper.get_session_by_id('1')
     self.assertEqual(ret, None)
     ret = SessionHelper.get_session_by_id(-1)
     self.assertEqual(ret, None)
     SessionHelper.add_session('IP')
     ret = SessionHelper.get_session_by_id(1)
     self.assertNotEqual(ret, None)
Beispiel #2
0
 def session_check(package):
     params = package['params']
     ip_address = package['ip']
     session = SessionHelper.get_session_id(params[ParamType.Token], ip_address)
     error = None
     if session is None:
         error = Response.error_response('No Session')
     else:
         package['session'] = session
         package['user'] = UserHelper.get_user_by_session(session)
     return package, error
Beispiel #3
0
    def verifyphone(testcase, phone):
        """send verify code
        """
        response = testcase.client.post('/user/sign/verify', {
            'token': testcase.token,
            'phone': phone
        })
        testcase.assertEqual(response.status_code, 200)
        data = analyse_response(response)
        testcase.assertEqual(data.get('msg'), 'Success')

        session = SessionHelper.get_session_id(testcase.token,
                                               testcase.ip_addr)
        verifycode = VerifyHelper.get_latest_code(session, phone)
        testcase.assertNotEqual(verifycode, None)
        code = verifycode.get('code')
        return code
Beispiel #4
0
 def basic_view(request):
     """basic view
     """
     ip_address = get_ip(request)
     if func is not start_session:
         package = {
             'request' : request,
             'ip' : ip_address,
             'method' : method,
             'paramlist' : paramlist,
             'checklist' : checklist,
             'action' : action,
             'file' : request.FILES.get('file', None)
         }
         for check in checks:
             package, error = check(package)
             if error is not None:
                 return error
         return func(package)
     token = SessionHelper.add_session(ip_address)
     return Response.success_response(data={'token' : token})
Beispiel #5
0
 def disconnect(testcase):
     """disconnect session for test
     """
     ret = SessionHelper.disconnect(testcase.token, testcase.ip_addr)
     testcase.assertEqual(ret, True)
Beispiel #6
0
 def test_0004(self):
     """
     Test Disconnect Failed
     """
     ret = SessionHelper.disconnect(233, 666)
     self.assertEqual(ret, False)
Beispiel #7
0
 def test_0003(self):
     """
     Test AddSession Failed
     """
     ret = SessionHelper.add_session(233)
     self.assertEqual(ret, None)
Beispiel #8
0
 def test_0001(self):
     """
     Test GetSession Failed
     """
     ret = SessionHelper.get_session_id(None, None)
     self.assertEqual(ret, None)