Ejemplo n.º 1
0
    def test_language_options_constraint(self):
        with self.app.app_context():
            from src.database.db import get_db
            from src.models.survey_model import Survey
            from neomodel.exception import DeflateError
            current_transaction = get_db().transaction
            with pytest.raises(DeflateError):
                with current_transaction:
                    test_survey_3 = Survey(
                        slug="test_survey_3",
                        language="Japanese"
                    )
                    test_survey_3.save()

            with current_transaction:
                test_survey_3.language = "en"
                test_survey_3.save()
                
                test_survey_3.language = "fr"
                test_survey_3.save()
Ejemplo n.º 2
0
 def test_language_required_constraint(self):
     with self.app.app_context():
         from src.database.db import get_db
         from neomodel.exceptions import RequiredProperty
         from src.models.survey_model import Survey
         transaction_factory = get_db()
         current_transaction = transaction_factory.transaction
         with pytest.raises(RequiredProperty):
             with current_transaction:
                 test_survey_2 = Survey(
                     slug="test_survey_2"
                 )
                 test_survey_2.save()
         current_transaction = transaction_factory.transaction
         with current_transaction:
             test_survey_2.language = "en"
             test_survey_2.save()