diff --git a/backend/tests/test_packages.py b/backend/tests/test_packages.py index 49ab533a..454f1402 100644 --- a/backend/tests/test_packages.py +++ b/backend/tests/test_packages.py @@ -6,7 +6,6 @@ import random import os from dotenv import load_dotenv -from test_signup import test_successful_sudo_signup load_dotenv() @@ -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. @@ -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: @@ -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") diff --git a/backend/tests/test_signup.py b/backend/tests/test_signup.py index 25f959a5..1bb8aece 100644 --- a/backend/tests/test_signup.py +++ b/backend/tests/test_signup.py @@ -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 \ No newline at end of file + self.assertEqual(200, response.status_code) \ No newline at end of file