示例#1
0
    def test_ModifUserGroup(self):
        '''
        测试 修改用户组信息
        :return:
        '''

        ugn = '测试1'
        pms = UserGroup.getAllPms()
        UserGroup.createNewUserGroup(ugn, pms)

        User.createRoot()

        ''' 渲染 '''
        settings.debug_username = User.rootAccount
        user = User.obj(username=settings.debug_username)
        data = {
            'oname': '测试1',
            'name': '原测试1',
        }

        for pmn in UserGroup.getPmNames():
            if random.randint(0, 1):
                data[pmn] = 'on'

        v = Views(user)
        v.html(self.appM.request(localpart=ModifUserGroup.URL, data=data, method='POST').data)
示例#2
0
    def test_nonstandardPW(self):
        '''
        非标注密码
        :return:
        '''
        self.redis.flushdb()

        ''' 密码过长 '''
        un = 'Shawn'
        pw = ''.join(['1' for i in range(user.ACCOUNT_MAX_SIZE+1)])
        try:
            err = '能够生成过 长 的密码!!'
            u = User.createNewUser(un, pw)
            raise ValueError(err)
        except :
            errInfo = traceback.format_exc()
            if err in errInfo:
                raise ValueError(errInfo)


        un = 'Shawn'
        pw = ''.join(['1' for i in range(user.ACCOUNT_MIN_SIZE-1)])
        try:
            err = '能够生成过 短 的密码!!'
            u = User.createNewUser(un, pw)
            raise ValueError(err)
        except:
            errInfo = traceback.format_exc()
            if err in errInfo:
                raise ValueError(errInfo)
示例#3
0
 def test_render_manage_user_option(self):
     '''
     渲染 管理用户选项
     :return:
     '''
     User.createRoot()
     user = User.obj(username=User.rootAccount)
     v = Views(user)
示例#4
0
 def test_render_manage_user(self):
     '''
     渲染 manage_user页面
     :return:
     '''
     User.createRoot()
     user = User.obj(username=User.rootAccount)
     views = Views(user)
     views.render_manage_user()
     views.html('manage_user')
示例#5
0
    def test_ManageUser(self):
        '''
        :return:
        '''

        User.createRoot()
        ''' 渲染 '''
        settings.debug_username = User.rootAccount
        user = User.obj(username=settings.debug_username)

        v = Views(user)
        v.html(self.appM.request(localpart=ManageUser.URL, method='GET').data)
示例#6
0
    def test_render_sim_terminal_page(self):
        '''
        测试 修改用户信息界面
        :return:
        '''
        user = User.obj(username=User.rootAccount)
        if not user:
            User.createRoot()
            user = User.obj(username=User.rootAccount)

        views = Views(user)
        views.render_sim_terminal_page(SimTermLocalServer)
        views.html('sim_terminal_page')
示例#7
0
    def test_render_modif_user(self):
        '''
        测试 修改用户信息界面
        :return:
        '''
        user = User.obj(username=User.rootAccount)
        if not user:
            User.createRoot()
            user = User.obj(username=User.rootAccount)

        views = Views(user)
        views.render_modif_user(user, ModifUserN, ModifUserPW, AddUG, RemoveUG)
        views.html('modif_user')
示例#8
0
    def test_createUser(self):
        '''
        :return:
        '''
        self.redis.flushdb()

        username, password = '******', '123456'
        u = User.createNewUser(username, password)

        print '生成用户完毕...'
        nu = User.obj(username=username)
        if not nu.is_valid:
            raise ValueError('生成玩家失败!!!')
        print '生成用户成功...'
示例#9
0
    def test_render_create_user_group(self):
        '''
        渲染 用户组信息列表
        :return:
        '''
        User.createRoot()
        user = User.obj(username=User.rootAccount)
        ugn = '测试1'
        pms = UserGroup.getAllPms()
        UserGroup.createNewUserGroup(ugn, pms)

        views = Views(user)
        views.render_create_user_group(CreateUserGroup)
        views.html('create_user_group')
示例#10
0
    def test_CreateUserGroup(self):
        '''
        测试 创建用户组
        :return:
        '''

        settings.debug_username = User.rootAccount

        user = User.obj(username=settings.debug_username)
        if not user:
            User.createRoot()
            user = User.obj(username=settings.debug_username)

        v = Views(user)
        v.html(self.appM.request(ManageUser.url).data)
示例#11
0
 def test_createSameNameUer(self):
     '''
     尝试生成同名用户
     :return:
     '''
     self.redis.flushdb()
     username, password = '******', 'bbb222'
     u = User.createNewUser(username, password)
     try:
         u = User.createNewUser(username, password)
     except:
         errInfo = traceback.format_exc()
         if user.NEW_ACCOUNT_ERR_NOT_UNIQUE in errInfo:
             print '不能创建重名账户...'
         else:
             raise errInfo
示例#12
0
    def test_SimTermLocalServer_GET(self):
        """
        测试 打开本地服务交互终端
        :return:
        """

        user = User.obj(username=User.rootAccount)
        if not user:
            User.createRoot()

        settings.debug_user = user
        ''' 渲染 '''
        v = Views(user)
        v.html(
            self.appM.request(localpart=SimTermLocalServer.URL,
                              method='GET').data)
示例#13
0
    def test_addUserGroup(self):
        '''
        测试 给用户添加用户组
        :return:
        '''

        ''' 清空数据库 '''
        self.redis.flushdb()

        ''' 生成测试用户 '''
        un = 'test01'
        pw = '123456'
        user = User.createNewUser(un, pw)

        ''' 生成测试用户组 '''
        ugn = 'testUG01'
        ug = UserGroup.createNewUserGroup(ugn)
        print 'ug->', id(ug), ug

        ''' 添加用户组 '''
        user.addUserGroup(ug)
        ug = UserGroup.obj(name=ugn)
        print 'ug->', id(ug), ug

        ''' 添加用户组 '''
        if ug not in user.userGroups:
            raise ValueError('添加  用户组失败')

        ''' 移除用户组 '''
        user.removeUserGroup(ug)
        if ug in user.userGroups:
            raise ValueError('移除 用户组失败')
示例#14
0
    def test_render_create_user(self):
        '''
        测试 渲染 创建用户 界面
        :return:
        '''

        self.redis.flushdb()
        User.createRoot()
        user = User.obj(username=User.rootAccount)

        ugn = '测试1'
        pms = UserGroup.getAllPms()
        UserGroup.createNewUserGroup(ugn, pms)

        views = Views(user)
        views.render_create_user(CreateUser)
        views.html('create_user')
示例#15
0
    def test_JavaHandler(self):
        """

        :return:
        """
        user = User.obj(username=User.rootAccount)
        settings.debug_user = user
        v = Views(user)
        v.html(self.appM.request(localpart=StaticJavaScripteHandler.load("jquery.min.js"), method='GET').data)
示例#16
0
 def test_session(self):
     """
     测试是否生成session实例
     :return:
     """
     user = User.obj(username='******')
     print user
     controllers.session().user = user
     print controllers.session().user
示例#17
0
 def test_css(self):
     """
     :return:
     """
     user = User.obj(username=User.rootAccount)
     settings.debug_user = user
     v = Views(user)
     print 1212, StaticCSSHandler.load("button.css")
     v.html(self.appM.request(localpart=StaticCSSHandler.load("button.css"), method='GET').data)
示例#18
0
    def test_SimTermLocalServer_POST(self):
        """
        测试 打开本地服务交互终端
        :return:
        """

        user = User.obj(username=User.rootAccount)
        if not user:
            User.createRoot()

        settings.debug_user = user
        data = {SimTermLocalServer.python_code: "a = u'aaa'\nprint a"}
        ''' 渲染 '''
        v = Views(user)
        v.html(
            self.appM.request(localpart=SimTermLocalServer.URL,
                              data=data,
                              method='POST').data)
示例#19
0
 def test_session(self):
     """
     测试是否生成session实例
     :return:
     """
     user = User.obj(username='******')
     print user
     controllers.session().user = user
     print controllers.session().user
示例#20
0
    def test_render_termial_output(self):
        """
        :return:
        """
        term_server = TerminalServer()
        term_server.term_title = '测试终端输出用'
        term_server.term_output = '测试终端输出的内容'

        term_output = [term_server, term_server]

        user = User.obj(username=User.rootAccount)
        if not user:
            User.createRoot()
            user = User.obj(username=User.rootAccount)

        views = Views(user)
        views.render_terminal_output(term_output)
        views.html('terminal_output')
示例#21
0
 def test_userAll(self):
     '''
     实例化所有角色
     :return:
     '''
     models.Init()
     users = User.all()
     print len(users)
     for u in users:
         print u.username
示例#22
0
    def test_test(self):
        """

        :return:
        """

        user = User.obj(username=User.rootAccount)
        settings.debug_user = user
        v = Views(user)

        v.html(self.appM.request(localpart=Test.URL, method='GET').data)
示例#23
0
    def test_objNoUser(self):
        '''
        获取一个不存在的用户
        :return:
        '''
        self.redis.flushdb()

        username = '******'
        u = User.obj(username=username)
        if u is not None:
            raise ValueError('不存在的用户不是None')
示例#24
0
    def test_creatRoot(self):
        '''
        创建root用户
        :return:
        '''
        self.redis.flushdb()

        root = User.createRoot()
        print 'root name ->', root.username
        rootUg = root.getUserGroupByName(User.rootAccount)

        print rootUg.pms
        print root.userGroups

        root.save()

        root = User.obj(username=User.rootAccount)
        rootUg = root.getUserGroupByName(UserGroup.rootGroup)

        print rootUg.pms
        print root.userGroups
示例#25
0
    def test_render_sim_term_local_server(self):
        """
        :return:
        """
        term_server = TerminalServer()
        term_server.term_title = '本地服务进程'
        term_server.term_output = '测试终端输出的内容'

        term_output = [term_server, term_server]

        user = User.obj(username=User.rootAccount)
        if not user:
            User.createRoot()
            user = User.obj(username=User.rootAccount)

        views = Views(user)
        views.render_terminal_output(term_output)
        views.render_terminal_input()

        views.render_sim_term_local_server(SimTermLocalServer)
        views.html('sim_term_local_server')
示例#26
0
    def test_render_user_list(self):
        '''
        渲染 用户列表
        :return:
        '''
        # self.redis.flushdb()

        user = User.obj(username=User.rootAccount)
        if not user:
            User.createRoot()
            user = User.obj(username=User.rootAccount)

        un = 'test1'
        pw = '123456'
        User.createNewUser(un, pw)

        views = Views(user)
        views.render_user_list(ModifUser)
        views.html('user_list')