Skip to content

Commit

Permalink
added test_trigger_deserialise_list_error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mudiwa Matanda authored and Mudiwa Matanda committed Feb 25, 2025
1 parent 2bef3d5 commit 0341de8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title,question_type,tags,slug,version,locale,high_result_page,high_inflection,medium_result_page,medium_inflection,low_result_page,skip_threshold,skip_high_result_page,generic_error,question,explainer,error,min,max,answers,scores,answer_semantic_ids,question_semantic_id,answer_responses
Test assessment pt,categorical_question,"pt,test",test-assessment-pt,,pt,,,,,,0,,Generic error,Q1,,,,,A1,"one, ""two, three'",a1,q1,""""""
Breastfeeding Quiz,categorical_question,"mnch,breastfeeding_quiz",breastfeeding-quiz,1,en,breastfeeding-quiz-champion,75,breastfeeding-quiz-good,25,breastfeeding-quiz-learner,100,,"Sorry, I didn't understand that. Please click one of the buttons.",*Question 1*,,,,,"Formula,Formula+breast milk,Breast milk only","one,two\nthree'","formula,formula-and-breast milk,breast-milk-only",baby-food@,"
"
13 changes: 13 additions & 0 deletions home/tests/test_assessment_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,19 @@ def test_invalid_score_field(self, csv_impexp: ImportExport) -> None:
)
assert e.value.row_num == 3

def test_trigger_deserialise_list_error(self, csv_impexp: ImportExport) -> None:
"""
Importing a CSV with invalid data that fails the deserialise_list fucntion
should return a valid error message
"""
with pytest.raises(ImportAssessmentException) as e:
csv_impexp.import_file("trigger_deserialise_list_error.csv")
assert (
e.value.message == "Invalid number format for score field. "
"The score value allows only a list of numbers separated by commas."
)
assert e.value.row_num == 2

def test_multiple_missing_headers(self, csv_impexp: ImportExport) -> None:
"""
Importing a CSV with multiple missing headers should return an error
Expand Down

0 comments on commit 0341de8

Please sign in to comment.