2015-06-15 09:55:54 +00:00
|
|
|
from datetime import date
|
|
|
|
|
|
|
|
from django.conf import settings
|
2020-11-22 12:21:54 +00:00
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from django.urls import reverse
|
2015-06-15 09:55:54 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
|
|
|
|
from symposion.conference.models import Section, current_conference, Conference
|
|
|
|
from symposion.schedule.models import Day, Schedule, Session
|
|
|
|
|
2020-11-22 12:21:54 +00:00
|
|
|
User = get_user_model()
|
|
|
|
|
2015-06-15 09:55:54 +00:00
|
|
|
|
|
|
|
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)
|