symposion_app/vendor/symposion/schedule/tests/test_views_session.py
Sachi King d95d66dac8 Taking one out of PyCon's (US) book
We're lock-step with symposion, and upstream is dead.
Vendor it.
2017-05-27 20:11:39 +10:00

58 lines
1.9 KiB
Python

from datetime import date
from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test import TestCase
from symposion.conference.models import Section, current_conference, Conference
from symposion.schedule.models import Day, Schedule, Session
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)