<commit_before>import os
import subprocess

from wizard_builder.models import (
    Choice, Conditional, FormQuestion, MultipleChoice, PageBase, QuestionPage,
    SingleLineText,
)

from django.test import TestCase


class InheritanceTest(TestCase):

    def test_question_page_instance(self):
        page = QuestionPage.objects.create()
        SingleLineText.objects.create(page_id=page.id)
        question = FormQuestion.objects.first()
        self.assertIsInstance(question.page, QuestionPage)

    def test_page_form_question_set_instance(self):
        page = QuestionPage.objects.create()
        SingleLineText.objects.create(page_id=page.id)
        question = PageBase.objects.first().formquestion_set.first()
        self.assertIsInstance(question, SingleLineText)

    def test_choice_multiple_choice_instance(self):
        page = QuestionPage.objects.create()
        question = MultipleChoice.objects.create(page_id=page.id)
        Choice.objects.create(question_id=question.id)
        choice = Choice.objects.first()
        self.assertIsInstance(choice.question, MultipleChoice)

    def test_conditional_instance(self):
        page = QuestionPage.objects.create()
        question = MultipleChoice.objects.create(page_id=page.id)
        Conditional.objects.create(question_id=question.id, page_id=page.id)
        condition = Conditional.objects.first()
        self.assertTrue(QuestionPage.objects.first().conditional)
        self.assertIsInstance(condition.question, MultipleChoice)
        self.assertIsInstance(condition.page, QuestionPage)


class DumpdataHackTest(TestCase):

    def test_dumpdata_hack(self):
        subprocess.check_call('python tests/test_app/manage.py dumpdata -o tests/test_app/dump.sql', shell=True)
        subprocess.check_call('python tests/test_app/manage.py loaddata tests/test_app/dump.sql', shell=True)<commit_msg>fixtures are json :p<commit_after>import os
import subprocess

from wizard_builder.models import (
    Choice, Conditional, FormQuestion, MultipleChoice, PageBase, QuestionPage,
    SingleLineText,
)

from django.test import TestCase


class InheritanceTest(TestCase):

    def test_question_page_instance(self):
        page = QuestionPage.objects.create()
        SingleLineText.objects.create(page_id=page.id)
        question = FormQuestion.objects.first()
        self.assertIsInstance(question.page, QuestionPage)

    def test_page_form_question_set_instance(self):
        page = QuestionPage.objects.create()
        SingleLineText.objects.create(page_id=page.id)
        question = PageBase.objects.first().formquestion_set.first()
        self.assertIsInstance(question, SingleLineText)

    def test_choice_multiple_choice_instance(self):
        page = QuestionPage.objects.create()
        question = MultipleChoice.objects.create(page_id=page.id)
        Choice.objects.create(question_id=question.id)
        choice = Choice.objects.first()
        self.assertIsInstance(choice.question, MultipleChoice)

    def test_conditional_instance(self):
        page = QuestionPage.objects.create()
        question = MultipleChoice.objects.create(page_id=page.id)
        Conditional.objects.create(question_id=question.id, page_id=page.id)
        condition = Conditional.objects.first()
        self.assertTrue(QuestionPage.objects.first().conditional)
        self.assertIsInstance(condition.question, MultipleChoice)
        self.assertIsInstance(condition.page, QuestionPage)


class DumpdataHackTest(TestCase):

    def test_dumpdata_hack(self):
        subprocess.check_call('python tests/test_app/manage.py dumpdata -o tests/test_app/dump.json', shell=True)
        subprocess.check_call('python tests/test_app/manage.py loaddata tests/test_app/dump.json', shell=True)
{'fraction_non_alphanumeric': 0.09545333687848977, 'fraction_numerical': 0.0, 'mean_word_length': 4.029411764705882, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4480442', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1048, 'n_words': 160}