Skip to content

Commit

Permalink
Merge pull request #3 from taptorestart/fix_tests
Browse files Browse the repository at this point in the history
TST: Fix paths of tests
  • Loading branch information
taptorestart authored May 7, 2023
2 parents 91f4987 + 24b7444 commit 0e6a8d9
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 9 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib.auth.models import User
from rest_framework.test import APIClient

from tests.api.factories import UserFactory
from tests.apis.factories import UserFactory


@pytest.fixture
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from django.utils import timezone

from apps.forms.models import Component
from tests.api.factories import ComponentFactory
from tests.api.factories import FormFactory
from tests.apis.factories import ComponentFactory
from tests.apis.factories import FormFactory


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from apis.v1.forms.serializers import SubmitSerializer, FormSerializer
from apps.forms.models import Choice
from apps.forms.models import Component
from tests.api.factories import ChoiceFactory
from tests.api.factories import ComponentFactory
from tests.apis.factories import ChoiceFactory
from tests.apis.factories import ComponentFactory


class TestFormSerializer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rest_framework.reverse import reverse

from apps.forms.models import Component, Choice
from tests.api.factories import ComponentFactory, ChoiceFactory
from tests.apis.factories import ComponentFactory, ChoiceFactory


@pytest.mark.urls(urls="apis.v1.urls")
Expand Down
Empty file added backend/tests/apps/__init__.py
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import datetime
from datetime import datetime, time

import pytest
from dateutil.relativedelta import relativedelta
from django.contrib.auth.models import User
from django.utils import timezone

from apps.forms.models import Component
from apps.forms.tasks import get_dataframe
from tests.api.factories import ComponentFactory, SubmitFactory, AnswerFactory, ChoiceFactory, UserFactory
from tests.apis.factories import ComponentFactory
from tests.apis.factories import FormFactory
from tests.apis.factories import SubmitFactory, AnswerFactory, ChoiceFactory, UserFactory


@pytest.mark.django_db
def test_get_dataframe(form):
def test_get_dataframe():
start_date = datetime.combine(timezone.now().replace(day=1), time.min)
end_date = datetime.combine(timezone.now().replace(day=1) + relativedelta(months=1), time.max)
form = FormFactory(slug="test", title="Form test", start_date=start_date, end_date=end_date)
user_staff: User = UserFactory(username="staff", is_staff=True)
ComponentFactory(form=form, type=Component.TITLE, title="title", order=1)
component_text = ComponentFactory(form=form, type=Component.TEXT, title="text", order=3)
component_select = ComponentFactory(form=form, type=Component.SELECT, title="select", order=2)
choice1 = ChoiceFactory(component=component_select, text="1.")
choice2 = ChoiceFactory(component=component_select, text="2.")
created_at = datetime.datetime(year=2023, month=5, day=1)
created_at = datetime(year=2023, month=5, day=1)
submit = SubmitFactory(user=user_staff, form=form)
submit.created_at = created_at
submit.save()
Expand Down

0 comments on commit 0e6a8d9

Please sign in to comment.