Skip to content

Commit

Permalink
test: bumping test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
marksweb committed Nov 25, 2023
1 parent 2cadbbb commit 5a9c1a0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ jobs:
py.test --cov
env:
POSTGRES_PASSWORD: postgres

6 changes: 6 additions & 0 deletions tests/applications/models/test_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@ def test_is_scored_by_user(application, user, another_user):

Score.objects.create(user=another_user, application=application, score=0)
assert application.is_scored_by_user(another_user) is False


def test_score_str(application, user, another_user):
score = Score.objects.create(user=user, application=application, score=3)

assert str(score) == f"{score.user} - {score.application}. Score {score.score}"
6 changes: 5 additions & 1 deletion tests/applications/views/test_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_access_applications_view(client, user_client, admin_client, future_even
resp = client.get(applications_url)
assert resp.status_code == 302

# as logged in user, but not orgarniser of given event
# as logged in user, but not organiser of given event
resp = user_client.get(applications_url)
assert resp.status_code == 404

Expand Down Expand Up @@ -125,6 +125,10 @@ def get_filtered_applications_list(
assert resp.context["applications"] == [application_waitlisted]


def test_application_str(admin_client, future_event, application_submitted):
assert str(application_submitted.id) == str(application_submitted)


def test_changing_application_status(admin_client, future_event, application_submitted):
assert application_submitted.state == "submitted"
resp = admin_client.post(
Expand Down
10 changes: 10 additions & 0 deletions tests/applications/views/test_applications_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,13 @@ def test_download_applications_list_with_question_added(
# column
assert csv_list[5][17] == "answer to last for app 5"
assert csv_list[5][18] == "answer to questionx for app 5"


def test_answer_str(admin_client, application_submitted, future_event, future_event_form, applications):
last_question = future_event_form.question_set.last()

new_application = Application.objects.create(form=future_event_form, state="submitted")
answer = Answer.objects.create(
application=new_application, question=last_question, answer="answer to last for app 5"
)
assert str(answer) == f"{answer.application} - {answer.question}"
5 changes: 5 additions & 0 deletions tests/core/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ def test_unfreeze_events_action(admin_client, future_event):
assert response.status_code == 200
assert Event.objects.filter(is_frozen=False).count() == 1
assert Event.objects.filter(is_on_homepage=True).count() == 1


def test_event_str(admin_client, events):
event = events[0]
assert str(event) == f"{event.name}, {event.date}"

0 comments on commit 5a9c1a0

Please sign in to comment.