Skip to content

Commit

Permalink
fix: fix linter suggested errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoub3bidi committed Feb 18, 2024
1 parent 818ce3a commit 49b0497
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/controllers/admin/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def update_user(user_id, payload, db):
user.update({"email": payload.email})
if payload.password:
user.update({"password": get_password_hash(payload.password)})
if payload.is_admin != None:
if payload.is_admin is not None:
user.update({"is_admin": payload.is_admin})
if payload.disabled != None:
if payload.disabled is not None:
User.disabled = user.disabled
user.update({"disabled": payload.disabled})

Expand Down
4 changes: 2 additions & 2 deletions src/controllers/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from utils.variables import is_not_empty

def register(payload, db):
if (validate_email(payload.email) == False):
if (validate_email(payload.email) is False):
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid email")
if (validate_password(payload.password) == False):
if (validate_password(payload.password) is False):
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid password")
user = db.query(User).filter(User.email == payload.email).first()
if user:
Expand Down
10 changes: 5 additions & 5 deletions src/integration_tests/test_admin_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
v = os.getenv("VERSION")

def test_get_users():
if (client != None):
if (client is not None):
response = client.get(f"/{v}/admin/user/all", headers=headers)
assert response.status_code == 200
assert len(response.json()) > 0

def test_get_user_by_id():
if (client != None):
if (client is not None):
response = client.get(f"/{v}/admin/user/1", headers=headers)
assert response.status_code == 200
assert response.json()["id"] == 1

def test_add_user():
if (client != None):
if (client is not None):
response = client.post(f"/{v}/admin/user/register", json={"username": "test_user", "email": "test_user@gmail.com", "password": "GoodPassword123", "is_admin": True, "disabled": False }, headers=headers)
assert response.status_code == 201
assert response.json()["username"] == "test_user"

def test_delete_user():
if (client != None):
if (client is not None):
response = client.delete(f"/{v}/admin/user/1", headers=headers)
assert response.text == None
assert response.text is None
2 changes: 1 addition & 1 deletion src/integration_tests/test_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
v = os.getenv("VERSION")

def test_get_health():
if (client != None):
if (client is not None):
response = client.get(f"/{v}/health")
assert response.status_code == 200
assert response.json() == { 'status': 'ok', 'alive': True }
2 changes: 1 addition & 1 deletion src/middleware/auth_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ async def get_current_active_user(current_user: UserRegisterSchema = Depends(get
return current_user

async def get_current_admin_user(current_user: UserRegisterSchema = Depends(get_current_user)):
if current_user.is_admin == False:
if current_user.is_admin is False:
raise HTTPException(status_code=400, detail="User is not admin")
return current_user

0 comments on commit 49b0497

Please sign in to comment.