Пример #1
0
class TestStudent(unittest.TestCase):
    redis = Redis()
    session = RedisStorage(redis)
    conf = {
        'name': '广东科技学院',
        'code': 'gdst',
        'login_url_path': '/default2.aspx', # 登录地址
        # 'exist_verify': False,            # 是否存在验证码
        'session': session,
        'login_view_state': {           # 登录的view_state(可空)
            'http://61.142.33.204/default2.aspx': 'dDw3OTkxMjIwNTU7Oz5vJ/yYUi9dD4fEnRUKesDFl8hEKA==',
            'http://61.142.33.204/default4.aspx': 'dDwxMTE4MjQwNDc1Ozs+MzFt0h81g6NGHTq1L9P2NfWUGLA='
        },
    }

    STUDENT_ACCOUNT = os.getenv('GDST_STUDENT_ACCOUNT', '')
    STUDENT_PASSWD = os.getenv('GDST_STUDENT_PASSWD', '')

    GdstApi = SchoolClient('http://61.142.33.204', **conf)
    student = GdstApi.user_login(STUDENT_ACCOUNT, STUDENT_PASSWD, timeout=3)

    def setUp(self):
        print('正在执行\033[1;35m %s \033[0m函数。' % self._testMethodName)

    def tearDown(self):
        pass

    def test_info(self):
        info_data = self.student.get_info(timeout=5)
        print(info_data)
Пример #2
0
class TestStudent(unittest.TestCase):
    redis = Redis()
    session = RedisStorage(redis)
    conf = {
        'name': '广东科技学院',
        'code': 'gdst',
        'login_url_path': '/default2.aspx', # 登录地址
        # 'exist_verify': False,            # 是否存在验证码
        'session': session,
    }

    STUDENT_ACCOUNT = os.getenv('GDST_STUDENT_ACCOUNT', '')
    STUDENT_PASSWD = os.getenv('GDST_STUDENT_PASSWD', '')

    GdstApi = SchoolClient('http://61.142.33.204', **conf)
    student = GdstApi.user_login(STUDENT_ACCOUNT, STUDENT_PASSWD, timeout=3)
    # 第二次 触发会话登录
    student = GdstApi.user_login(STUDENT_ACCOUNT, STUDENT_PASSWD, timeout=3)

    def setUp(self):
        print('正在执行\033[1;35m %s \033[0m函数。' % self._testMethodName)

    def tearDown(self):
        pass

    def test_info(self):
        info_data = self.student.get_info(timeout=5)
        print(info_data)
Пример #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from redis import Redis

from school_api import SchoolClient
from school_api.session.redisstorage import RedisStorage

redis = Redis()
session = RedisStorage(redis)
conf = {
    'name': '广东科技学院',
    'code': 'gdst',
    'login_url_path': '/default2.aspx',  # 登录地址
    'session': session,
}

GdstApi = SchoolClient('http://61.142.33.204', **conf)
student = GdstApi.user_login('user', 'password', timeout=3)

info_data = student.get_info(timeout=5)
print(info_data)
Пример #4
0
# -*- coding: utf-8 -*-
from app import redis_school
from school_api import SchoolClient
from school_api.session.redisstorage import RedisStorage
from app.utils import service_resp, random_string

session = RedisStorage(redis_school)


class School(object):
    def __init__(self, url):
        self.school_client = SchoolClient(url,
                                          session=session,
                                          use_ex_handle=False)

    @service_resp()
    def get_login(self, account, password):
        '''首次登陆验证'''
        self.user = self.school_client.user_login(account,
                                                  password,
                                                  use_cookie=False)
        return {"token": random_string(16)}

    @service_resp()
    def get_auth_user(self, account):
        '''使用会话,免密码登陆'''
        auth_user = self.school_client.user_login(account, None)
        return auth_user


class Client(object):