Skip to content

Commit

Permalink
Add fixture, unit test for loading fixtures with supplementary charac…
Browse files Browse the repository at this point in the history
…ters
  • Loading branch information
ssciolla committed Aug 10, 2020
1 parent b44a9ab commit 0d0999d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/fixtures/test_05.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"model": "pe.report",
"pk": 4,
"fields": {
"name": "Divination 🔮",
"contact": "[email protected]"
}
},
{
"model": "pe.exam",
"pk": 4,
"fields": {
"sa_code": "Δ",
"name": "Δ𓀤𝌕👁",
"report_id": 4,
"course_id": 1111111,
"assignment_id": 777777,
"default_time_filter": "2020-08-01T00:00:00Z"
}
}
]
9 changes: 9 additions & 0 deletions test/test_pe.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ def test_fixtures_load_maintains_submission_link(self):
self.assertEqual(submission.exam.sa_code, 'PP')
self.assertEqual(submission.exam.name, 'Potions Placement Advanced')

def test_load_fixtures_with_supplementary_characters(self):
"""Loading exam and report fixtures with characters that need utf8mb4 encoding succeeds."""
call_command('loaddata', 'test_05.json')
div_report: Report = Report.objects.get(id=4)
self.assertEqual(div_report.name, 'Divination 🔮')
div_exam: Exam = div_report.exams.first()
self.assertEqual(div_exam.sa_code, 'Δ')
self.assertEqual(div_exam.name, 'Δ𓀤𝌕👁')


class StringMethodsTestCase(TestCase):
fixtures: List[str] = ['test_01.json', 'test_04.json']
Expand Down

0 comments on commit 0d0999d

Please sign in to comment.