Skip to content

Commit

Permalink
add some tests for the new models
Browse files Browse the repository at this point in the history
  • Loading branch information
nmenezes0 committed Dec 31, 2024
1 parent 7cba8af commit e66a773
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/unit/models/test_factories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Test factories for the new consultation models.
"""
import pytest
from consultation_analyser import factories2


@pytest.mark.django_db
def test_factories():
# just check nothing fails
factories2.UserFactory()
factories2.Consultation2Factory()
factories2.QuestionGroupFactory()
factories2.Question2Factory()
factories2.QuestionPartFactory()
factories2.ExpandedQuestionFactory()
factories2.RespondentFactory()
factories2.Answer2Factory()
factories2.ExecutionRunFactory()
factories2.FrameworkFactory()
factories2.Theme2Factory()
factories2.ThemeMappingFactory()
factories2.SentimentMappingFactory()
29 changes: 29 additions & 0 deletions tests/unit/models/test_slug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest

from consultation_analyser.factories2 import Consultation2Factory, Question2Factory


@pytest.mark.django_db
def test_consultation_save():
consultation_title = "My First Consultation"
slugified = "my-first-consultation"
consultation = Consultation2Factory(text=consultation_title)
assert consultation.slug.startswith(slugified)
another_consultation = Consultation2Factory(text=consultation_title)
assert another_consultation.slug != consultation.slug
assert another_consultation.slug.startswith(slugified)


@pytest.mark.django_db
def test_question_save():
question_text = "What are your thoughts on the proposed changes?"
slugified = "what-are-your-thoughts-on-the-proposed-changes"
question = Question2Factory(text=question_text)
assert question.slug.startswith(slugified)
another_question = Question2Factory(text=question_text)
assert another_question.slug != question.slug
assert another_question.slug.startswith(slugified)




0 comments on commit e66a773

Please sign in to comment.