symposion_app/vendor/symposion/schedule/tests/test_views_session.py
Joel Addison 252697b842 Update to Django 2.2
Upgrade site and modules to Django 2.2. Remove and replace obsolete
functionality with current equivalents. Update requirements to latest
versions where possible. Remove unused dependencies.
2020-11-22 23:58:14 +10:00

60 lines
1.9 KiB
Python

from datetime import date
from django.conf import settings
from django.contrib.auth import get_user_model
from django.urls import reverse
from django.test import TestCase
from symposion.conference.models import Section, current_conference, Conference
from symposion.schedule.models import Day, Schedule, Session
User = get_user_model()
class TestScheduleViews(TestCase):
username = "user@example.com"
first_name = "Sam"
last_name = "McGillicuddy"
def setUp(self):
self.user = User.objects.create_user(self.username,
password="pass",
email=self.username)
self.user.first_name = self.first_name
self.user.last_name = self.last_name
self.user.save()
def test_session_list(self):
# Really minimal test for session list
rsp = self.client.get(reverse("schedule_session_list"))
self.assertEqual(200, rsp.status_code)
def test_session_staff_email(self):
# login and staff required
self.user.is_staff = True
self.user.save()
assert self.client.login(username=self.username, password="pass")
url = reverse("schedule_session_staff_email")
rsp = self.client.get(url)
self.assertEqual(200, rsp.status_code)
def test_session_detail(self):
# really minimal test
Conference.objects.get_or_create(id=settings.CONFERENCE_ID)
section = Section.objects.create(
conference=current_conference(),
)
schedule = Schedule.objects.create(
section=section,
)
day = Day.objects.create(
schedule=schedule,
date=date.today(),
)
session = Session.objects.create(
day=day,
)
url = reverse("schedule_session_detail", args=(session.pk,))
rsp = self.client.get(url)
self.assertEqual(200, rsp.status_code)