Exemplo n.º 1
0
 def get(self,user_id):
     #查询出fans数最多的用户100个用户
     user_detail = UserDao()
     try:
         datas = user_detail.get_user(user_id)
     except:
         return self.render("error.html", message="服务器错误")
     return self.render("user_detail.html", datas = datas)
Exemplo n.º 2
0
 def get(self):
     #查询出fans数最多的用户100个用户
     hot_user = UserDao()
     try:
         datas = hot_user.hosUser()
     except:
         return self.render("error.html", message="服务器错误")
     return self.render("list_follower.html", datas = datas)
Exemplo n.º 3
0
 def post(self):
     #查询出fans数最多的用户100个用户
     text = self.get_argument("text")
     userdao = UserDao()
     try:
         result = userdao.search(text)
         return self.render("list_user.html", result = result)
     except:
         self.render("error.html", message="没有该用户")
Exemplo n.º 4
0
 def get(self, follower_id):
     '''
     创建关注关系
     '''
     user_id = self.get_secure_cookie("user")
     userdao = UserDao()
     try:
         sign = userdao.del_follower(user_id, follower_id)
     except:
         return self.render("error.html", message="服务器错误")
     self.set_secure_cookie("user", user_id)
     self.redirect("/list_follower")
Exemplo n.º 5
0
 def post(self):
     name = self.get_argument("user")
     platform = self.get_argument("platform")
     password = self.get_argument("password")
     userdao = UserDao()
     try:
         sign, user = userdao.register_or_login(name=name, platform=platform, password=password)
     except:
         return self.render("error.html", message="服务器错误")
     if sign:
         self.set_secure_cookie("user", str(user.id))
         self.render("success.html", user_id=user.id)
     else:
         #注册或者登录失败,返回登录页
         self.render("register.html")
Exemplo n.º 6
0
from core.vo.user import User

class FakeUserDateSource(DataSource):
    def fetchone(self, sql, values):
        return (1, 'macbin', 'ning', '*****@*****.**', 'nibcam', 123456789)

    def fetchall(self, sql, values):
        return [
            (1, 'macbin', 'ning', '*****@*****.**', 'nibcam', 123456789),
            (1, 'macbin', 'ning', '*****@*****.**', 'nibcam', 123456789),
            (1, 'macbin', 'ning', '*****@*****.**', 'nibcam', 123456789),
            ]


UserDao._datasource = FakeUserDateSource()
user_dao = UserDao()

class TestUser(TestCase):
    def test_query_by_id(self):
        print user_dao.query_user_by_id(1)

    def test_find(self):
        print user_dao.find(1)

    def test_query_user_by_email(self):
        print user_dao.query_user_by_email('*****@*****.**')

    def test_query_users(self):
        print user_dao.query_users()

    def test_insert_user(self):