diff --git a/src/controllers/admin/user.py b/src/controllers/admin/user.py index efb75bf..db5f595 100644 --- a/src/controllers/admin/user.py +++ b/src/controllers/admin/user.py @@ -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}) diff --git a/src/controllers/user/user.py b/src/controllers/user/user.py index 01c6fc0..23563e7 100644 --- a/src/controllers/user/user.py +++ b/src/controllers/user/user.py @@ -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: diff --git a/src/integration_tests/test_admin_user.py b/src/integration_tests/test_admin_user.py index 37dc0bf..16f0c98 100644 --- a/src/integration_tests/test_admin_user.py +++ b/src/integration_tests/test_admin_user.py @@ -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 \ No newline at end of file + assert response.text is None \ No newline at end of file diff --git a/src/integration_tests/test_health.py b/src/integration_tests/test_health.py index d5fe8e9..2cf500e 100644 --- a/src/integration_tests/test_health.py +++ b/src/integration_tests/test_health.py @@ -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 } \ No newline at end of file diff --git a/src/middleware/auth_guard.py b/src/middleware/auth_guard.py index 471de6d..afb0d9c 100644 --- a/src/middleware/auth_guard.py +++ b/src/middleware/auth_guard.py @@ -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 \ No newline at end of file