Skip to content

Commit

Permalink
style: pr recommendation for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johanseto committed Jul 10, 2023
1 parent e371330 commit de7a82f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion eox_nelp/course_experience/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def map_attributes_from_instance_to_dict(instance, attributes_mapping):
instance_dict: dict representing the instance
"""
instance_dict = {}
for extra_field, instance_field in attributes_mapping.items():
for extra_field, instance_field in attributes_mapping.items():
extra_value = None
instance_level = copy(instance)
for instance_field in instance_field.split("__"):
Expand Down
11 changes: 3 additions & 8 deletions eox_nelp/course_experience/api/v1/tests/mixins_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
from rest_framework import status
from rest_framework.test import APIClient

from eox_nelp.course_experience.api.v1.serializers import (
COURSE_OVERVIEW_EXTRA_FIELD_MAPPING,
USER_EXTRA_FIELD_MAPPING,
map_attributes_from_instance_to_dict,
)
from eox_nelp.course_experience.api.v1.serializers import get_course_extra_attributes, get_user_extra_attributes
from eox_nelp.course_experience.api.v1.views import INVALID_KEY_ERROR
from eox_nelp.edxapp_wrapper.course_overviews import CourseOverview

Expand Down Expand Up @@ -53,14 +49,14 @@ def make_relationships_data(self):
"data": {
"type": "User",
"id": f"{self.user.id}",
"attributes": map_attributes_from_instance_to_dict(self.user, USER_EXTRA_FIELD_MAPPING),
**get_user_extra_attributes(self.user)
}
},
"course_id": {
"data": {
"type": "CourseOverview",
"id": f"{self.my_course.id}",
"attributes": map_attributes_from_instance_to_dict(self.user, COURSE_OVERVIEW_EXTRA_FIELD_MAPPING),
**get_course_extra_attributes(self.my_course)
}
},
}
Expand Down Expand Up @@ -115,7 +111,6 @@ def test_patch_object_json(self):
expected_data["data"]["attributes"].update(self.patch_data)

response = self.client.patch(url_endpoint, self.patch_data, format="json")

self.assertIn(response.headers["Content-Type"], RESPONSE_CONTENT_TYPES)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json(), expected_data)
Expand Down

0 comments on commit de7a82f

Please sign in to comment.