def generate_user(i): return User( name="%s%s" % (internet.user_name(), i), password=basic.text(8, at_least=8, spaces=False), email=internet.email_address(), phone=basic.text(11, at_least=11, lowercase=False, uppercase=False, spaces=False), info=lorem_ipsum.paragraphs(), photo="%s.jpg" % i, uuid=uuid4().hex, )
def test_user_role_set(self): user = User(name=internet.user_name(), email=internet.email_address(), password=basic.text()) db.session.add(user) db.session.commit() self.assrtEqual(user.role.name, 'Guests')
def generate_user(): return User( email=internet.email_address(), name=internet.user_name(), password=basic.text(6, at_least=6, at_most=10, spaces=False), roles=guests )
def test_user_role_set(self): user = User(name=internet.user_name(), email=internet.email_address(), password=basic.text()) db.session.add(user) db.session.commit() self.assertEqual(user.role.name, 'Guests')
def test_user_login(self): from login_page import LoginPage new_user = User(name=internet.user_name(), email=internet.email_address(), password=basic.text()) db.session.add(new_user) db.session.commit() page = LoginPage(self.client) self.client.get('http://localhost:5000/auth/login') self.assertTrue(u'登录' in page.title) page.set_user_name(new_user.name) page.set_pwd(new_user.password) page.submit() # 返回注册结果 self.assertTrue(re.search(u'欢迎来到Ray的博客', self.client.page_source))
def test_user_login(self): from login_page import LoginPage passwd = basic.text() username = internet.user_name() new_user = User(name=username, email=internet.email_address(), password=passwd) db.session.add(new_user) db.session.commit() # print(username,"+",passwd,"+",new_user) page = LoginPage(self.client) self.client.get("http://localhost:5000/auth/login") self.assertTrue(u"登录" in self.client.title) # 因为models 设置 page.set_user_name(username) page.set_pwd(passwd) page.submit() self.assertTrue(re.search(u'欢迎来到Alan博客', self.client.page_source))
def test_user_login(self): from login_page import LoginPage new_user = User(name=internet.user_name(), email=internet.email_address(), password=basic.text()) db.session.add(new_user) db.session.commit() page = LoginPage(self.client) self.client.get('http://localhost:5000/auth/login') self.assertTrue(u'登录' in self.client.title) page.set_user_name(new_user.name) page.set_user_password(new_user.password) page.submit() # return the login result self.assertTrue(re.search(u'欢迎来到Gregory的博客', self.client.page_source))
def test_user_login(self): # 建立一个模拟用户 new_user = User(name=internet.user_name(), email=internet.email_address(), password=basic.text()) db.session.add(new_user) db.session.commit() # 获取登录界面 self.client.get("http://localhost:5000/auth/login") self.assertTrue('登录' in self.client.title) # 设置登录用户名和密码 user_name = self.client.find_element_by_name('user') user_name.send_keys(new_user.name) pwd = self.client.find_element_by_name('password') pwd.send_keys(new_user.password) submit = self.client.find_element_by_name('submit') submit.click() # 获得登录跳转页面的信息 self.assertTrue(re.search(r'', self.client.page_source))
def generate_user(): return User(name=internet.user_name(), email=internet.email_address(), password=basic.text(length=6, at_least=6, spaces=False), role=guests)
def generate_user(): return User(name=internet.user_name(), email=internet.email_address(), password=basic.text(6, at_least=6, spaces=False), role=guests)
def test_user_login(self): from login_page import LoginPage new_user = User(name=internet.user_name(), email=internet.email_address(), password=basic.text()) db.session.add(new_user) db.session.commit() page = LoginPage(self.client) self.client.get("http://localhost:5000/auth/login") self.assertTrue(u"登录" in page.title) page.set_user_name(new_user.name) page.set_pwd(new_user.password) page.submit() # 返回注册结果 self.assertTrue(re.search(u"欢迎来到Ray的博客", self.client.page_source))