Exemplo n.º 1
0
def test_del_user_api_case1(admin_login, username):
    client, app = admin_login
    with app.app_context():
        id = User.get_user_by_username(username).id
    rv = client.post("/api/user/delete", data={"id": id})
    d = rv.get_json()
    assert d['status'] == 200
    with app.app_context():
        user = User.get_user_by_username(username)
        assert user is None
Exemplo n.º 2
0
 def test_add_user1(self,app):
     with app.app_context():
         user=User.create_user(username='******',password='******',salt='kxxh',email='test@test',activation='act',type=2,status=2)
         assert user is not None
         user=User.get_user_by_username('zjm')
         assert user is not None
         assert user.salt=="kxxh"
Exemplo n.º 3
0
 def post(self):
     d = self.parser.parse_args()
     user = User.get_user_by_username(d['username'])
     if user is None:
         return Base_Response_Fields("ok")
     elif d.get("id", None) is not None:
         id = d.get("id")
         n_user = User.get_user_by_id(id)
         if n_user.username == d.get("username"):
             return Base_Response_Fields("ok")
     else:
         return Base_Response_Fields("该用户名已被注册!", USERNAME_DUPLICATE)
Exemplo n.º 4
0
def test_add_user_api_case1(admin_login, username, password, email):
    client, app = admin_login
    rv = client.post("/api/user/add",
                     data={
                         "username": username,
                         "password": password,
                         "email": email
                     })
    d = rv.get_json()
    assert d['status'] == 200
    with app.app_context():
        user = User.get_user_by_username(username)
        assert user.check_password(password)
Exemplo n.º 5
0
 def post(self):
     d = self.parser.parse_args()
     if d['end_time'] < d['start_time']:
         abort(400)
     if "user_id" in d:
         user = User.get_user_by_id(d['user_id'])
     elif "username" in d:
         user = User.get_user_by_username(d['username'])
         if user is None:
             abort(404)
     else:
         abort(400)
     block = Block.create_block(user.id, d['reason'], d['start_time'],
                                d['end_time'])
     print(block)
     flash(
         "用户 %s 已因为%s 从 %s 被封禁到 %s" %
         (block.user.username, d['reason'], d['start_time'], d['end_time']),
         "warning")
     return Base_Response_Fields("ok")
Exemplo n.º 6
0
 def test_user_delete1(self,app):
     with app.app_context():
         user=User.get_user_by_username("test2")
         assert user is not None
         user.delete_user()
Exemplo n.º 7
0
 def test_get_user_by_username(self,app):
     with app.app_context():
         user=User.get_user_by_username("test1")
         assert user is not None