Mercurial > public > sg101
view contests/tests/view_tests.py @ 693:ad69236e8501
For issue #52, update many 3rd party Javascript libraries.
Updated to jquery 1.10.2, jquery ui 1.10.3.
This broke a lot of stuff.
- Found a newer version of the jquery cycle all plugin (3.0.3).
- Updated JPlayer to 2.4.0.
- Updated to MarkItUp 1.1.14. This also required me to add multiline attributes
set to true on various buttons in the markdown set.
- As per a stackoverflow post, added some code to get multiline titles in
a jQuery UI dialog. They removed that functionality but allow you to put it
back.
Tweaked the MarkItUp preview CSS to show blockquotes in italic.
Did not update TinyMCE at this time. I'm not using the JQuery version and this
version appears to work ok for now.
What I should do is make a repo for MarkItUp and do a vendor branch thing so
I don't have to futz around diffing directories to figure out if I'll lose
changes when I update.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 04 Sep 2013 19:55:20 -0500 |
parents | 89b240fe9297 |
children |
line wrap: on
line source
""" View tests for the contests application. """ import datetime import json from django.test import TestCase from django.contrib.auth.models import User from django.core.urlresolvers import reverse from contests.models import Contest class NoConstestsTestCase(TestCase): def test_no_contests(self): response = self.client.get(reverse('contests-index')) self.assertEqual(response.status_code, 200) url = reverse('contests-contest', kwargs={'slug': 'test'}) response = self.client.get(url) self.assertEqual(response.status_code, 404) class ConstestsTestCase(TestCase): def setUp(self): now = datetime.datetime.now() start = now - datetime.timedelta(days=7) end = start - datetime.timedelta(days=3) user = User.objects.create_user('test_user', '', 'password') user.save() c = Contest(title='test', slug='test', description='test', is_public=True, creation_date=start, end_date=end, winner=user, win_date=end + datetime.timedelta(days=1)) c.save() self.contest_id = c.id def test_contests(self): response = self.client.get(reverse('contests-index')) self.assertEqual(response.status_code, 200) url = reverse('contests-contest', kwargs={'slug': 'test'}) response = self.client.get(url) self.assertEqual(response.status_code, 200) class ContestEntryTestCase(TestCase): def setUp(self): self.username = 'test_user' self.pw = 'password' self.user = User.objects.create_user(self.username, '', self.pw) self.user.save() self.assertTrue(self.client.login(username=self.username, password=self.pw)) now = datetime.datetime.now() start = now - datetime.timedelta(days=7) end = now + datetime.timedelta(days=3) c = Contest(title='test', slug='test', description='test', is_public=True, creation_date=start, end_date=end) c.save() self.contest_id = c.id def test_entry_toggle(self): response = self.client.post(reverse('contests-enter'), {'contest_id': self.contest_id}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') self.assertEqual(response.status_code, 200) c = json.loads(response.content) self.assertTrue(c['entered']) contest = Contest.objects.get(pk=self.contest_id) self.assertTrue(self.user in contest.contestants.all()) response = self.client.post(reverse('contests-enter'), {'contest_id': self.contest_id}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') self.assertEqual(response.status_code, 200) c = json.loads(response.content) self.failIf(c['entered']) contest = Contest.objects.get(pk=self.contest_id) self.failIf(self.user in contest.contestants.all()) class NoPublicConstestsTestCase(TestCase): def setUp(self): now = datetime.datetime.now() start = now - datetime.timedelta(days=7) end = start - datetime.timedelta(days=3) c = Contest(title='test', slug='test', description='test', is_public=False, creation_date=start, end_date=end) c.save() def test_contests(self): response = self.client.get(reverse('contests-index')) self.assertEqual(response.status_code, 200) url = reverse('contests-contest', kwargs={'slug': 'test'}) response = self.client.get(url) self.assertEqual(response.status_code, 404)