Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxcutex committed Feb 3, 2021
1 parent f7f765c commit de1e1a0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion app/controllers/user_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,15 @@ def create_user(self):
f"User with email '{email}' already exists", status_code=400
)
try:
user = self.user_repo.new_user(*user_info).serialize()
user = self.user_repo.new_user(
first_name,
last_name,
email,
gender,
date_of_birth,
location_id,
password,
).serialize()
del user["password"]
user_role = self.user_role_repo.new_user_role(
role_id=role_id, user_id=user["id"]
Expand Down
2 changes: 1 addition & 1 deletion app/repositories/user_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def new_user(
date_of_birth,
location_id,
password,
employment_date,
employment_date=datetime.datetime.now().strftime("%Y-%m-%d"),
):
"""
function for creating a new user
Expand Down
2 changes: 2 additions & 0 deletions factories/user_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Meta:
image_url = factory.Faker("url")
gender = "male"
date_of_birth = fake.date_between()
employment_date = fake.date_between()
is_active = True
is_deleted = False

Expand All @@ -42,5 +43,6 @@ class Meta:
image_url = factory.Faker("url")
gender = "male"
date_of_birth = fake.date_between()
employment_date = fake.date_between()
is_active = True
is_deleted = False
3 changes: 3 additions & 0 deletions tests/integration/endpoints/test_user_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,10 @@ def test_create_user_endpoint_succeeds(self):
role_id=role.id,
gender=user.gender,
date_of_birth=str(user.date_of_birth),
employment_date=str(user.employment_date),
password=user.password,
email=user.email,
location_id=user.location_id,
)

response = self.client().post(
Expand All @@ -331,6 +333,7 @@ def test_create_user_endpoint_succeeds(self):
)

response_json = self.decode_from_json_string(response.data.decode("utf-8"))
print(response_json)
self.assertEqual(response.status_code, 201)
self.assertEqual(response_json["msg"], "OK")
self.assertEqual(
Expand Down
1 change: 0 additions & 1 deletion tests/unit/repositories/test_user_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test_new_user_method_returns_new_user_object(self):
user.first_name,
user.last_name,
user.email,
role.id,
"male",
datetime.datetime.now().strftime("%Y-%m-%d"),
1,
Expand Down

0 comments on commit de1e1a0

Please sign in to comment.