Skip to content

Commit

Permalink
fix(#2495): Fix tests failing after community role changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pbanaszkiewicz committed Nov 27, 2024
1 parent de7dd57 commit a97edea
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
34 changes: 34 additions & 0 deletions amy/dashboard/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.test import TestCase

from communityroles.models import CommunityRole, CommunityRoleConfig
from dashboard.forms import GetInvolvedForm, SignupForRecruitmentForm
from recruitment.models import InstructorRecruitment
from trainings.models import Involvement
Expand Down Expand Up @@ -53,6 +54,17 @@ def test_clean_custom_validation__no_dates_event(self):
person = Person.objects.create(
personal="Test", family="User", email="[email protected]"
)
config = CommunityRoleConfig.objects.create(
name="instructor",
display_name="Instructor",
link_to_award=False,
link_to_membership=False,
additional_url=False,
)
CommunityRole.objects.create(
config=config,
person=person,
)
event = Event.objects.create(slug="test-event", host=host) # no dates
recruitment = InstructorRecruitment.objects.create(status="o", event=event)
data = {}
Expand All @@ -69,6 +81,17 @@ def test_clean_custom_validation__no_conflicting_tasks(self):
person = Person.objects.create(
personal="Test", family="User", email="[email protected]"
)
config = CommunityRoleConfig.objects.create(
name="instructor",
display_name="Instructor",
link_to_award=False,
link_to_membership=False,
additional_url=False,
)
CommunityRole.objects.create(
config=config,
person=person,
)
event = Event.objects.create(
slug="test-event", host=host, start=date(2022, 2, 19), end=date(2022, 2, 20)
)
Expand All @@ -87,6 +110,17 @@ def test_clean_custom_validation__conflicting_tasks(self):
person = Person.objects.create(
personal="Test", family="User", email="[email protected]"
)
config = CommunityRoleConfig.objects.create(
name="instructor",
display_name="Instructor",
link_to_award=False,
link_to_membership=False,
additional_url=False,
)
CommunityRole.objects.create(
config=config,
person=person,
)
event = Event.objects.create(
slug="test-event", host=host, start=date(2022, 2, 19), end=date(2022, 2, 20)
)
Expand Down
12 changes: 12 additions & 0 deletions amy/dashboard/tests/test_instructor_recruitment_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,18 @@ def test_form_valid__creates_a_new_signup(self, mock_contrib_messages_views):
)
recruitment = InstructorRecruitment.objects.create(status="o", event=event)

config = CommunityRoleConfig.objects.create(
name="instructor",
display_name="Instructor",
link_to_award=False,
link_to_membership=False,
additional_url=False,
)
CommunityRole.objects.create(
config=config,
person=person,
)

request = RequestFactory().post("/")
request.user = person
view = SignupForRecruitment(
Expand Down
8 changes: 1 addition & 7 deletions amy/recruitment/tests/test_forms.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from django.db.utils import IntegrityError
from django.test import TestCase

from communityroles.models import (
CommunityRole,
CommunityRoleConfig,
CommunityRoleInactivation,
)
from communityroles.models import CommunityRole, CommunityRoleConfig
from recruitment.forms import (
InstructorRecruitmentAddSignupForm,
InstructorRecruitmentChangeStateForm,
Expand Down Expand Up @@ -57,11 +53,9 @@ def _prepare_person(self) -> Person:
link_to_membership=False,
additional_url=False,
)
inactivation = CommunityRoleInactivation.objects.create(name="inactivation")
CommunityRole.objects.create(
config=config,
person=person,
inactivation=inactivation,
)
return person

Expand Down
8 changes: 1 addition & 7 deletions amy/recruitment/tests/test_instructor_recruitment_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
from django.test.client import RequestFactory
from django.urls import reverse

from communityroles.models import (
CommunityRole,
CommunityRoleConfig,
CommunityRoleInactivation,
)
from communityroles.models import CommunityRole, CommunityRoleConfig
from emails.types import StrategyEnum
from recruitment.filters import InstructorRecruitmentFilter
from recruitment.forms import (
Expand Down Expand Up @@ -585,11 +581,9 @@ def test_integration(self) -> None:
link_to_membership=False,
additional_url=False,
)
inactivation = CommunityRoleInactivation.objects.create(name="inactivation")
CommunityRole.objects.create(
config=config,
person=person,
inactivation=inactivation,
)
notes = "Lorem ipsum"
data = {"person": person.pk, "notes": notes}
Expand Down

0 comments on commit a97edea

Please sign in to comment.