Skip to content

Commit

Permalink
code formatted using black
Browse files Browse the repository at this point in the history
  • Loading branch information
Raghunandhan8818 committed Aug 26, 2023
1 parent 4d19fbb commit af40f49
Show file tree
Hide file tree
Showing 39 changed files with 0 additions and 84 deletions.
2 changes: 0 additions & 2 deletions app/api/dao/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def assign_new_user(user_id: int, data: Dict[str, str]):
new_admin_user = UserModel.find_by_id(new_admin_user_id)

if new_admin_user:

if new_admin_user.is_admin:
return messages.USER_IS_ALREADY_AN_ADMIN, HTTPStatus.BAD_REQUEST

Expand Down Expand Up @@ -82,7 +81,6 @@ def revoke_admin_user(user_id: int, data: Dict[str, str]):
return messages.USER_NOT_FOUND, HTTPStatus.NOT_FOUND

if new_admin_user:

if not new_admin_user.is_admin:
return messages.USER_IS_NOT_AN_ADMIN, HTTPStatus.BAD_REQUEST

Expand Down
1 change: 0 additions & 1 deletion app/api/dao/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def delete_user(user_id: int):

# check if this user is the only admin
if user.is_admin:

admins_list_count = len(UserModel.get_all_admins())
if admins_list_count <= UserDAO.MIN_NUMBER_OF_ADMINS:
return messages.USER_CANT_DELETE, HTTPStatus.BAD_REQUEST
Expand Down
1 change: 0 additions & 1 deletion app/api/resources/mentorship_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def post(cls):

@staticmethod
def is_valid_data(data):

# Verify if request body has required fields
if "mentor_id" not in data:
return messages.MENTOR_ID_FIELD_IS_MISSING
Expand Down
1 change: 0 additions & 1 deletion app/api/resources/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def post(cls, relation_id):

@staticmethod
def is_valid_data(data):

if "description" not in data:
return messages.DESCRIPTION_FIELD_IS_MISSING

Expand Down
2 changes: 0 additions & 2 deletions app/database/models/mentorship_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def __init__(
notes,
tasks_list,
):

self.action_user_id = action_user_id
self.mentor = mentor_user
self.mentee = mentee_user # same as mentee_user.mentee_relations.append(self)
Expand Down Expand Up @@ -99,7 +98,6 @@ def json(self):

@classmethod
def find_by_id(cls, _id) -> "MentorshipRelationModel":

"""Returns the mentorship that has the passed id.
Args:
_id: The id of a mentorship.
Expand Down
9 changes: 0 additions & 9 deletions tests/admin/test_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class TestAdminDao(BaseTestCase):
"""

def test_dao_assign_new_admin_valid_user(self):

dao = AdminDAO()

user = UserModel(
Expand Down Expand Up @@ -44,7 +43,6 @@ def test_dao_assign_new_admin_valid_user(self):
"""

def test_dao_assign_new_admin_by_normal_user(self):

dao = AdminDAO()

user = UserModel(
Expand Down Expand Up @@ -73,7 +71,6 @@ def test_dao_assign_new_admin_by_normal_user(self):
"""

def test_dao_assign_admin_role_to_non_existing_user(self):

dao = AdminDAO()

data = dict(user_id=123)
Expand All @@ -89,7 +86,6 @@ def test_dao_assign_admin_role_to_non_existing_user(self):
"""

def test_dao_assign_admin_role_to_admin_user(self):

dao = AdminDAO()

user = UserModel(
Expand Down Expand Up @@ -122,7 +118,6 @@ def test_dao_assign_admin_role_to_admin_user(self):
"""

def test_dao_assign_admin_role_to_myself(self):

dao = AdminDAO()

user = UserModel(
Expand Down Expand Up @@ -155,7 +150,6 @@ def test_dao_assign_admin_role_to_myself(self):
"""

def test_dao_revoke_admin_role_to_valid_user(self):

dao = AdminDAO()

user = UserModel(
Expand Down Expand Up @@ -184,7 +178,6 @@ def test_dao_revoke_admin_role_to_valid_user(self):
"""

def test_dao_revoke_admin_role_by_non_admin_user(self):

dao = AdminDAO()

user = UserModel(
Expand All @@ -211,7 +204,6 @@ def test_dao_revoke_admin_role_by_non_admin_user(self):
"""

def test_dao_revoke_admin_role_to_non_existing_user(self):

dao = AdminDAO()

data = dict(user_id=123)
Expand All @@ -227,7 +219,6 @@ def test_dao_revoke_admin_role_to_non_existing_user(self):
"""

def test_dao_revoke_admin_role_to_non_admin_user(self):

dao = AdminDAO()

user = UserModel(
Expand Down
2 changes: 0 additions & 2 deletions tests/cron_job_functions/test_mentorship_completion_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class TestCompleteMentorshipRelationCronFunction(BaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down Expand Up @@ -105,7 +104,6 @@ def get_test_app(self):

@patch("run.application", side_effect=get_test_app)
def test_complete_mentorship_relations_accepted(self, get_test_app_fn):

self.assertEqual(
MentorshipRelationState.ACCEPTED, self.mentorship_relation_1.state
)
Expand Down
1 change: 0 additions & 1 deletion tests/mentorship_relation/relation_base_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class MentorshipRelationBaseTestCase(BaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down
1 change: 0 additions & 1 deletion tests/mentorship_relation/test_api_cancel_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class TestCancelMentorshipRelationApi(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down
1 change: 0 additions & 1 deletion tests/mentorship_relation/test_api_delete_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class TestDeleteMentorshipRequestApi(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down
1 change: 0 additions & 1 deletion tests/mentorship_relation/test_api_list_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class TestListMentorshipRelationsApi(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down
1 change: 0 additions & 1 deletion tests/mentorship_relation/test_api_reject_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class TestRejectMentorshipRequestApi(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down
1 change: 0 additions & 1 deletion tests/mentorship_relation/test_dao_accept_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class TestMentorshipRelationAcceptRequestDAO(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down
1 change: 0 additions & 1 deletion tests/mentorship_relation/test_dao_cancel_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class TestMentorshipRelationListingDAO(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down
3 changes: 0 additions & 3 deletions tests/mentorship_relation/test_dao_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class TestMentorshipRelationCreationDAO(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
def setUp(self):
super().setUp()
Expand Down Expand Up @@ -160,7 +159,6 @@ def test_dao_create_mentorship_relation_with_non_existent_mentee(self):
self.assertIsNone(query_mentorship_relation)

def test_dao_create_mentorship_relation_with_mentee_already_in_relation(self):

self.mentorship_relation = MentorshipRelationModel(
action_user_id=self.admin_user.id,
mentor_user=self.admin_user,
Expand Down Expand Up @@ -196,7 +194,6 @@ def test_dao_create_mentorship_relation_with_mentee_already_in_relation(self):
self.assertTrue(1, len(query_mentorship_relations))

def test_dao_create_mentorship_relation_with_mentor_already_in_relation(self):

self.mentorship_relation = MentorshipRelationModel(
action_user_id=self.admin_user.id,
mentor_user=self.admin_user,
Expand Down
5 changes: 0 additions & 5 deletions tests/mentorship_relation/test_dao_delete_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class TestMentorshipRelationDeleteDAO(BaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down Expand Up @@ -69,7 +68,6 @@ def setUp(self):
db.session.commit()

def test_dao_delete_non_existing_mentorship_request(self):

result = MentorshipRelationDAO.delete_request(self.first_user.id, 123)

self.assertEqual(
Expand All @@ -83,7 +81,6 @@ def test_dao_delete_non_existing_mentorship_request(self):
)

def test_dao_sender_does_not_exist(self):

result = MentorshipRelationDAO.delete_request(123, self.mentorship_relation.id)

self.assertEqual((messages.USER_DOES_NOT_EXIST, HTTPStatus.NOT_FOUND), result)
Expand All @@ -94,7 +91,6 @@ def test_dao_sender_does_not_exist(self):
)

def test_dao_receiver_tries_to_delete_mentorship_request(self):

result = MentorshipRelationDAO.delete_request(
self.second_user.id, self.mentorship_relation.id
)
Expand Down Expand Up @@ -126,7 +122,6 @@ def test_dao_sender_delete_mentorship_request(self):
)

def test_dao_user_not_involved_tries_to_delete_mentorship_request(self):

result = MentorshipRelationDAO.delete_request(
self.admin_user.id, self.mentorship_relation.id
)
Expand Down
4 changes: 0 additions & 4 deletions tests/mentorship_relation/test_dao_list_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class TestListMentorshipRelationsDAO(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
def setUp(self):
super().setUp()
Expand Down Expand Up @@ -63,7 +62,6 @@ def setUp(self):
db.session.commit()

def test_dao_list_past_mentorship_relations(self):

result = MentorshipRelationDAO.list_past_mentorship_relations(
user_id=self.first_user.id
)
Expand All @@ -74,7 +72,6 @@ def test_dao_list_past_mentorship_relations(self):
self.assertEqual(expected_response, result[0])

def test_dao_list_current_mentorship_relation(self):

result = MentorshipRelationDAO.list_current_mentorship_relation(
user_id=self.first_user.id
)
Expand All @@ -91,7 +88,6 @@ def test_dao_list_non_existing_current_mentorship_relation(self):
self.assertEqual(expected_response, result)

def test_dao_list_pending_mentorship_relation(self):

result = MentorshipRelationDAO.list_pending_mentorship_relations(
user_id=self.first_user.id
)
Expand Down
1 change: 0 additions & 1 deletion tests/mentorship_relation/test_dao_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class TestMentorshipRelationListingDAO(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
def setUp(self):
super().setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class TestMentorshipRelationListingDAO(MentorshipRelationBaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down
1 change: 0 additions & 1 deletion tests/mentorship_relation/test_database_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class TestMentorshipRelationModel(BaseTestCase):

# Setup consists of adding 2 users into the database
def setUp(self):
db.create_all()
Expand Down
1 change: 0 additions & 1 deletion tests/tasks/tasks_base_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class TasksBaseTestCase(BaseTestCase):

# Setup consists of adding 2 users into the database
# User 1 is the mentorship relation requester = action user
# User 2 is the receiver
Expand Down
1 change: 0 additions & 1 deletion tests/tasks/test_api_complete_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def test_complete_task_api_resource_non_auth(self):
self.assertDictEqual(expected_response, json.loads(actual_response.data))

def test_complete_task_api(self):

relation = MentorshipRelationModel.find_by_id(
self.mentorship_relation_w_second_user.id
)
Expand Down
1 change: 0 additions & 1 deletion tests/tasks/test_api_create_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def test_create_task_api_resource_non_auth(self):
self.assertDictEqual(expected_response, json.loads(actual_response.data))

def test_full_task_creation_api(self):

non_existent_task = self.tasks_list_1.find_task_by_id(3)
self.assertIsNone(non_existent_task)

Expand Down
1 change: 0 additions & 1 deletion tests/tasks/test_api_delete_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def test_delete_task_api_w_user_not_belonging_to_mentorship_relation_2(self):
self.assertDictEqual(expected_response, json.loads(actual_response.data))

def test_full_task_deletion_api(self):

existent_task = self.tasks_list_1.find_task_by_id(2)
self.assertIsNotNone(existent_task)

Expand Down
4 changes: 0 additions & 4 deletions tests/tasks/test_api_list_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def test_list_tasks_api_resource_non_auth(self):
self.assertDictEqual(expected_response, json.loads(actual_response.data))

def test_list_tasks_api_first_mentorship_relation(self):

auth_header = get_test_request_header(self.first_user.id)
expected_response = marshal(self.tasks_list_1.tasks, list_tasks_response_body)
actual_response = self.client.get(
Expand All @@ -37,7 +36,6 @@ def test_list_tasks_api_first_mentorship_relation(self):
self.assertEqual(expected_response, json.loads(actual_response.data))

def test_list_tasks_api_second_mentorship_relation(self):

auth_header = get_test_request_header(self.first_user.id)
expected_response = marshal(self.tasks_list_2.tasks, list_tasks_response_body)
actual_response = self.client.get(
Expand All @@ -50,7 +48,6 @@ def test_list_tasks_api_second_mentorship_relation(self):
self.assertEqual(expected_response, json.loads(actual_response.data))

def test_list_tasks_api_w_user_not_belonging_to_mentorship_relation(self):

auth_header = get_test_request_header(self.second_user.id)
expected_response = messages.USER_NOT_INVOLVED_IN_THIS_MENTOR_RELATION
actual_response = self.client.get(
Expand All @@ -63,7 +60,6 @@ def test_list_tasks_api_w_user_not_belonging_to_mentorship_relation(self):
self.assertDictEqual(expected_response, json.loads(actual_response.data))

def test_list_tasks_api_mentorship_relation_without_tasks(self):

auth_header = get_test_request_header(self.second_user.id)
expected_response = []
actual_response = self.client.get(
Expand Down
1 change: 0 additions & 1 deletion tests/tasks/test_dao_complete_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def test_achieve_achieved_task(self):
self.assertEqual(expected_response, actual_response)

def test_achieve_not_existent_task(self):

expected_response = messages.TASK_DOES_NOT_EXIST, HTTPStatus.NOT_FOUND
actual_response = TaskDAO.complete_task(
self.first_user.id, self.mentorship_relation_w_second_user.id, 123123
Expand Down
Loading

0 comments on commit af40f49

Please sign in to comment.