Skip to content

Commit

Permalink
feat: unpack test
Browse files Browse the repository at this point in the history
  • Loading branch information
johanseto committed Jul 11, 2024
1 parent 571c2e8 commit 9806c06
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions eox_nelp/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ExtractCourseIdFromStringTestCase: Tests cases for the extract_course_id_from_string method.
GetCourseFromIdTestCase: Tests cases for the get_course_from_id method.
"""
from ddt import data, ddt
from ddt import data, ddt, unpack
from django.contrib.auth import get_user_model
from django.test import TestCase
from mock import Mock, patch
Expand Down Expand Up @@ -237,37 +237,35 @@ def test_invalid_input(self, input_value):
class SaveExtraInfoFieldTestCase(TestCase):
"""Test class for the save_extrainfo_field method."""
@data(
("arabic_name", "أناكين سكاي ووكر"),
("is_phone_validated", True),
("arabic_first_name", " أناكين"),
("arabic_last_name", "سكاي ووكر"),
{"field": "arabic_name", "value": "أناكين سكاي ووكر"},
{"field": "is_phone_validated", "value": True},
{"field": "arabic_first_name", "value": " أناكين"},
{"field": "arabic_last_name", "value": "سكاي ووكر"},
)
def test_save_extrainfo_field(self, test_data):
@unpack
def test_save_extrainfo_field(self, field, value):
""" Test right functionality.
Expected behavior:
- Extrainfo related objed has the expected value.
"""
field = test_data[0]
value = test_data[1]
user, _ = User.objects.get_or_create(username="vader1798")

save_extrainfo_field(user, field, value)

self.assertEqual(getattr(user.extrainfo, field), value)

@data(
("arabic_name2", "loool"),
("otp-crazy", True),
{"field": "arabic_name2", "value": "loool"},
{"field": "otp-crazy", "value": True},
)
def test_wrong_extra_info_field(self, test_data):
@unpack
def test_wrong_extra_info_field(self, field, value):
""" Test when the input is not a extra info field.
Expected behavior:
- The user has no extra info model.
"""
field = test_data[0]
value = test_data[1]
user, _ = User.objects.get_or_create(username="vader19")

save_extrainfo_field(user, field, value)
Expand Down

0 comments on commit 9806c06

Please sign in to comment.