Skip to content

Commit

Permalink
update tests for new text
Browse files Browse the repository at this point in the history
  • Loading branch information
elichad committed Jul 25, 2023
1 parent 4a3bbac commit 5ce498e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
40 changes: 26 additions & 14 deletions amy/dashboard/tests/test_instructor_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.urls import reverse

from trainings.models import Involvement
from workshops.models import Award, Person, TrainingProgress, TrainingRequirement
from workshops.models import Award, Event, Person, TrainingProgress, TrainingRequirement
from workshops.tests.base import TestBase


Expand Down Expand Up @@ -104,7 +104,17 @@ def setUp(self):
self.progress_url = reverse("training-progress")

def test_training_passed(self):
TrainingProgress.objects.create(trainee=self.admin, requirement=self.training)
self._setUpTags()
self._setUpOrganizations()
event = Event.objects.create(
slug="event-ttt",
start=date(2023, 6, 24),
end=date(2023, 6, 25),
host=self.org_alpha,
)
TrainingProgress.objects.create(
trainee=self.admin, requirement=self.training, event=event
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Training passed")

Expand All @@ -113,18 +123,18 @@ def test_training_failed(self):
trainee=self.admin, requirement=self.training, state="f"
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Training not passed yet")
self.assertContains(rv, "Training failed")

def test_training_asked_to_repeat(self):
TrainingProgress.objects.create(
trainee=self.admin, requirement=self.training, state="a"
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Training not passed yet")
self.assertContains(rv, "Training asked to repeat")

def test_training_not_finished(self):
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Training not passed yet")
self.assertContains(rv, "Training not completed yet")


class TestGetInvolvedStatus(TestBase):
Expand Down Expand Up @@ -158,7 +168,7 @@ def test_get_involved_waiting_to_be_evaluated(self):
url="https://example.org",
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Get Involved step evaluation pending")
self.assertContains(rv, "Get Involved not evaluated yet")

def test_get_involved_passed(self):
TrainingProgress.objects.create(
Expand All @@ -169,7 +179,7 @@ def test_get_involved_passed(self):
url="https://example.org",
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Get Involved submission accepted")
self.assertContains(rv, "Get Involved passed")

def test_submission_form(self):
data = {
Expand All @@ -181,7 +191,9 @@ def test_submission_form(self):
rv = self.client.post(self.progress_url, data, follow=True)
self.assertEqual(rv.status_code, 200)
self.assertEqual(rv.resolver_match.view_name, "training-progress")
self.assertContains(rv, "Your Get Involved submission will be evaluated soon.")
self.assertContains(
rv, "Your Get Involved submission will be reviewed within 7-10 days."
)
got = list(
TrainingProgress.objects.values_list(
"state", "trainee", "url", "requirement", "involvement_type", "date"
Expand Down Expand Up @@ -244,11 +256,11 @@ def test_session_failed(self):
trainee=self.admin, requirement=self.welcome, state="f"
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Welcome Session not passed yet")
self.assertContains(rv, "Welcome Session failed")

def test_no_participation_in_a_session_yet(self):
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Welcome Session not passed yet")
self.assertContains(rv, "Welcome Session not completed yet")


class TestDemoSessionStatus(TestBase):
Expand All @@ -261,20 +273,20 @@ def setUp(self):
name="Demo", defaults={}
)
self.progress_url = reverse("training-progress")
self.SESSION_LINK_TEXT = "You can register for a Demo Session on"
self.SESSION_LINK_TEXT = "Register for a Demo Session on"

def test_session_passed(self):
TrainingProgress.objects.create(trainee=self.admin, requirement=self.demo)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Demo Session passed")
self.assertContains(rv, "Demo passed")
self.assertNotContains(rv, self.SESSION_LINK_TEXT)

def test_session_failed(self):
TrainingProgress.objects.create(
trainee=self.admin, requirement=self.demo, state="f"
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Demo Session not completed")
self.assertContains(rv, "Demo failed")
self.assertContains(rv, self.SESSION_LINK_TEXT)

def test_no_participation_in_a_session_yet(self):
Expand All @@ -285,5 +297,5 @@ def test_no_participation_in_a_session_yet(self):
def test_no_registration_instruction_when_trainee_passed_session(self):
TrainingProgress.objects.create(trainee=self.admin, requirement=self.demo)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Demo Session passed")
self.assertContains(rv, "Demo passed")
self.assertNotContains(rv, self.SESSION_LINK_TEXT)
10 changes: 6 additions & 4 deletions amy/templates/dashboard/training_progress.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ <h2>Your progress towards becoming a Carpentries Instructor</h2>
{% elif user.passed_training %}
<div class="alert alert-info" role="alert">
<p>
{% checkout_deadline progress_training.event.end as deadline %}
Please review your progress towards Instructor certification below.
Based on your training dates of {% human_daterange progress_training.event.start progress_training.event.end %}, the 90-day deadline to complete these
requirements is {{ deadline }}.
{% if progress_training %}
{% checkout_deadline progress_training.event.end as deadline %}
Please review your progress towards Instructor certification below.
Based on your training dates of {% human_daterange progress_training.event.start progress_training.event.end %}, the 90-day deadline to complete these
requirements is {{ deadline }}.
{% endif %}
</p>
If you would like an extension, please contact us at
<a href="mailto:[email protected]">[email protected]</a>
Expand Down

0 comments on commit 5ce498e

Please sign in to comment.