-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop Django 3.1 support & update tests
- Loading branch information
Ferdinand Hoffmann
committed
Jun 10, 2021
1 parent
c706c7b
commit e0d4b18
Showing
9 changed files
with
230 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
coverage | ||
django-ordered-model | ||
psycopg2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,179 @@ | ||
[{"model": "questionnaire_core.questionnaire", "pk": 1, "fields": {"title": "test1"}}, {"model": "questionnaire_core.question", "pk": 1, "fields": {"order": 0, "questionnaire": 1, "question_text": "boolean (checkbox)", "question_type": "boolean", "question_options": {}, "required": true}}, {"model": "questionnaire_core.question", "pk": 2, "fields": {"order": 1, "questionnaire": 1, "question_text": "boolean (yes/no)", "question_type": "boolean_yesno", "question_options": {}, "required": true}}, {"model": "questionnaire_core.question", "pk": 3, "fields": {"order": 2, "questionnaire": 1, "question_text": "choices", "question_type": "choices", "question_options": {"choices": [{"value": "1", "label": "first"}, {"value": "2", "label": "second"}]}, "required": true}}, {"model": "questionnaire_core.question", "pk": 4, "fields": {"order": 3, "questionnaire": 1, "question_text": "choices multiple", "question_type": "choices_multiple", "question_options": {"choices": [{"value": "1", "label": "first"}, {"value": "2", "label": "second"}]}, "required": true}}, {"model": "questionnaire_core.question", "pk": 5, "fields": {"order": 4, "questionnaire": 1, "question_text": "file upload", "question_type": "file_upload", "question_options": {}, "required": true}}, {"model": "questionnaire_core.question", "pk": 6, "fields": {"order": 5, "questionnaire": 1, "question_text": "multiple text", "question_type": "multiple_text", "question_options": {}, "required": true}}, {"model": "questionnaire_core.question", "pk": 7, "fields": {"order": 6, "questionnaire": 1, "question_text": "number decimal", "question_type": "number_decimal", "question_options": {}, "required": true}}, {"model": "questionnaire_core.question", "pk": 8, "fields": {"order": 7, "questionnaire": 1, "question_text": "number integer", "question_type": "number_integer", "question_options": {}, "required": true}}, {"model": "questionnaire_core.question", "pk": 9, "fields": {"order": 8, "questionnaire": 1, "question_text": "number percent", "question_type": "number_percent", "question_options": {}, "required": true}}, {"model": "questionnaire_core.question", "pk": 10, "fields": {"order": 9, "questionnaire": 1, "question_text": "range slider", "question_type": "range_slider", "question_options": {"max": 100, "step": 1, "min": 1}, "required": true}}, {"model": "questionnaire_core.question", "pk": 11, "fields": {"order": 10, "questionnaire": 1, "question_text": "text long", "question_type": "text_long", "question_options": {}, "required": true}}, {"model": "questionnaire_core.question", "pk": 12, "fields": {"order": 11, "questionnaire": 1, "question_text": "text short", "question_type": "text_short", "question_options": {}, "required": true}}] | ||
[ | ||
{ | ||
"model": "questionnaire_core.questionnaire", | ||
"pk": 1, | ||
"fields": { | ||
"title": "test1" | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 1, | ||
"fields": { | ||
"order": 0, | ||
"questionnaire": 1, | ||
"question_text": "boolean (checkbox)", | ||
"question_type": "boolean", | ||
"question_options": {}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 2, | ||
"fields": { | ||
"order": 1, | ||
"questionnaire": 1, | ||
"question_text": "boolean (yes/no)", | ||
"question_type": "boolean_yesno", | ||
"question_options": {}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 3, | ||
"fields": { | ||
"order": 2, | ||
"questionnaire": 1, | ||
"question_text": "choices", | ||
"question_type": "choices", | ||
"question_options": { | ||
"choices": [ | ||
{ | ||
"value": "1", | ||
"label": "first" | ||
}, | ||
{ | ||
"value": "2", | ||
"label": "second" | ||
} | ||
] | ||
}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 4, | ||
"fields": { | ||
"order": 3, | ||
"questionnaire": 1, | ||
"question_text": "choices multiple", | ||
"question_type": "choices_multiple", | ||
"question_options": { | ||
"choices": [ | ||
{ | ||
"value": "1", | ||
"label": "first" | ||
}, | ||
{ | ||
"value": "2", | ||
"label": "second" | ||
} | ||
] | ||
}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 5, | ||
"fields": { | ||
"order": 4, | ||
"questionnaire": 1, | ||
"question_text": "file upload", | ||
"question_type": "file_upload", | ||
"question_options": {}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 6, | ||
"fields": { | ||
"order": 5, | ||
"questionnaire": 1, | ||
"question_text": "multiple text", | ||
"question_type": "multiple_text", | ||
"question_options": {}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 7, | ||
"fields": { | ||
"order": 6, | ||
"questionnaire": 1, | ||
"question_text": "number decimal", | ||
"question_type": "number_decimal", | ||
"question_options": {}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 8, | ||
"fields": { | ||
"order": 7, | ||
"questionnaire": 1, | ||
"question_text": "number integer", | ||
"question_type": "number_integer", | ||
"question_options": {}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 9, | ||
"fields": { | ||
"order": 8, | ||
"questionnaire": 1, | ||
"question_text": "number percent", | ||
"question_type": "number_percent", | ||
"question_options": {}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 10, | ||
"fields": { | ||
"order": 9, | ||
"questionnaire": 1, | ||
"question_text": "range slider", | ||
"question_type": "range_slider", | ||
"question_options": { | ||
"max": 100, | ||
"step": 1, | ||
"min": 1 | ||
}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 11, | ||
"fields": { | ||
"order": 10, | ||
"questionnaire": 1, | ||
"question_text": "text long", | ||
"question_type": "text_long", | ||
"question_options": {}, | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"model": "questionnaire_core.question", | ||
"pk": 12, | ||
"fields": { | ||
"order": 11, | ||
"questionnaire": 1, | ||
"question_text": "text short", | ||
"question_type": "text_short", | ||
"question_options": {}, | ||
"required": true | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from django.test import TestCase | ||
|
||
from questionnaire_core.models import Question, Questionnaire | ||
|
||
|
||
class ModelTestCase(TestCase): | ||
|
||
def test_ordering_create(self): | ||
"""Questions are ordered in creation order""" | ||
test_questionnaire = Questionnaire.objects.create(title='test_ordering_1') | ||
Question.objects.create( | ||
questionnaire=test_questionnaire, | ||
question_type='boolean', | ||
question_text='question 1', | ||
) | ||
Question.objects.create( | ||
questionnaire=test_questionnaire, | ||
question_type='boolean', | ||
question_text='question 2', | ||
) | ||
|
||
self.assertEqual(test_questionnaire.questions.get(question_text='question 1').order, 0) | ||
self.assertEqual(test_questionnaire.questions.get(question_text='question 2').order, 1) | ||
|
||
def test_ordering_bulk_create(self): | ||
"""Questions are ordered in creation order by bulk_create()""" | ||
test_questionnaire = Questionnaire.objects.create(title='test_ordering_2') | ||
Question.objects.bulk_create([ | ||
Question( | ||
questionnaire=test_questionnaire, | ||
question_type='boolean', | ||
question_text='question 1', | ||
), | ||
Question( | ||
questionnaire=test_questionnaire, | ||
question_type='boolean', | ||
question_text='question 2', | ||
), | ||
]) | ||
|
||
self.assertEqual(test_questionnaire.questions.get(question_text='question 1').order, 0) | ||
self.assertEqual(test_questionnaire.questions.get(question_text='question 2').order, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters