-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Distinguish between upcoming and past events.
- Loading branch information
1 parent
a61e961
commit 65b80f3
Showing
9 changed files
with
133 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Run tests | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
env: | ||
ENVIRONMENT: 'dev' | ||
DJANGO_SETTINGS_MODULE: 'indymeet.settings.dev' | ||
SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python version | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements/requirements-test.txt | ||
- name: Run tests | ||
run: python manage.py test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,8 @@ | |
width: 100%; | ||
height: 150px; | ||
} | ||
|
||
.no-data-img { | ||
width: 100%; | ||
height: 150px; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from datetime import datetime, timezone | ||
|
||
from django.test import Client, TestCase | ||
from django.urls import reverse | ||
from freezegun import freeze_time | ||
|
||
from home.models import Event | ||
|
||
|
||
@freeze_time("2012-01-14") | ||
class EventListViewTests(TestCase): | ||
def setUp(self): | ||
self.client = Client() | ||
|
||
@staticmethod | ||
def create_upcoming_event(): | ||
return Event.objects.create( | ||
title="Testathon 5.0", | ||
slug="testathon-5", | ||
start_time=datetime(2023, 2, 1, 10, 0, tzinfo=timezone.utc), | ||
end_time=datetime(2023, 2, 1, 11, 0, tzinfo=timezone.utc), | ||
location="zoom", | ||
status=Event.SCHEDULED, | ||
) | ||
|
||
@staticmethod | ||
def create_past_event(): | ||
return Event.objects.create( | ||
title="Coffee Chat", | ||
slug="coffee-chat", | ||
start_time=datetime(2010, 2, 1, 10, 0, tzinfo=timezone.utc), | ||
end_time=datetime(2010, 2, 1, 11, 0, tzinfo=timezone.utc), | ||
location="zoom", | ||
status=Event.SCHEDULED, | ||
) | ||
|
||
def test_no_events(self): | ||
url = reverse("event_list") | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTemplateUsed("home/prerelease/event_list.html") | ||
self.assertContains(response, "No upcoming events.") | ||
self.assertContains(response, "No past events.") | ||
|
||
def test_upcoming_events_no_past(self): | ||
upcoming_event = self.create_upcoming_event() | ||
url = reverse("event_list") | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTemplateUsed("home/prerelease/event_list.html") | ||
self.assertNotContains(response, "No upcoming events.") | ||
self.assertContains(response, "No past events.") | ||
self.assertContains(response, upcoming_event.title) | ||
self.assertContains(response, upcoming_event.get_absolute_url()) | ||
|
||
def test_upcoming_events_and_past(self): | ||
upcoming_event = self.create_upcoming_event() | ||
past_event = self.create_past_event() | ||
url = reverse("event_list") | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTemplateUsed("home/prerelease/event_list.html") | ||
self.assertNotContains(response, "No upcoming events.") | ||
self.assertNotContains(response, "No past events.") | ||
self.assertContains(response, upcoming_event.title) | ||
self.assertContains(response, upcoming_event.get_absolute_url()) | ||
self.assertContains(response, past_event.title) | ||
self.assertContains(response, past_event.get_absolute_url()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,2 @@ | ||
-r requirements.txt | ||
pytest | ||
pytest-cov | ||
pytest-django | ||
pytest-django | ||
tox | ||
freezegun |