Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
henilp105 committed Mar 24, 2024
1 parent 5502c97 commit e9b2a6a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 3 additions & 5 deletions backend/tests/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import random
import os
from dotenv import load_dotenv
from test_signup import test_successful_sudo_signup

load_dotenv()

Expand Down Expand Up @@ -36,7 +35,7 @@ def setUp(self):
"namespace_description": "Test namespace description",
}

def login(self):
def login(self,is_sudo=False):
"""
Helper function to signup and login a user.
Expand All @@ -52,7 +51,7 @@ def login(self):

signup_data = {
"email": self.email,
"password": self.password,
"password": self.password if not is_sudo else os.getenv("SUDO_PASSWORD"),
"username": self.username,
}
if self.is_created:
Expand Down Expand Up @@ -544,8 +543,7 @@ def test_successful_fetch_malicious_reports(self):
AssertionError: If the response code received from the server is not as expected.
"""

test_successful_sudo_signup = test_successful_sudo_signup() # create a sudo user
access_token = test_successful_sudo_signup["access_token"]
access_token = self.login(is_sudo=True) # create a sudo user
response = self.client.get("/report/view",headers={"Authorization": f"Bearer {access_token}"})
self.assertEqual(200, response.json["code"])
print("test_successful_fetch_malicious_reports passed")
Expand Down
3 changes: 1 addition & 2 deletions backend/tests/test_signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,4 @@ def test_successful_sudo_signup(self):
}

response = self.client.post('/auth/signup', data=data)
self.assertEqual(200, response.status_code)
return response.json
self.assertEqual(200, response.status_code)

0 comments on commit e9b2a6a

Please sign in to comment.