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)
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)
def test_session(self): """ 测试是否生成session实例 :return: """ user = User.obj(username='******') print user controllers.session().user = user print controllers.session().user
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')
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')
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)
def test_objNoUser(self): ''' 获取一个不存在的用户 :return: ''' self.redis.flushdb() username = '******' u = User.obj(username=username) if u is not None: raise ValueError('不存在的用户不是None')
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')
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)
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 '生成用户成功...'
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')
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)
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')
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)
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