Commit c2666439094534b92beb4f05de2b31bf0683636a
1 parent
967471203f
Exists in
master
fixed up section list test error
Showing 1 changed file with 14 additions and 4 deletions Inline Diff
flashcards/tests/test_models.py
View file @
c266643
from django.test import TestCase | 1 | 1 | from django.test import TestCase | |
from flashcards.models import User | 2 | 2 | from flashcards.models import User, Section | |
3 | 3 | |||
4 | 4 | |||
class UserTests(TestCase): | 5 | 5 | class UserTests(TestCase): | |
def setUp(self): | 6 | 6 | def setUp(self): | |
u = User.objects.create(email="none@none.com",password="1234") | 7 | 7 | User.objects.create(email="none@none.com", password="1234") | |
8 | Section.objects.create(department='dept', | |||
9 | course_num='101a', | |||
10 | course_title='how 2 test', | |||
11 | instructor='George Lucas', | |||
12 | quarter='SP15') | |||
8 | 13 | |||
def test_section_list(self): | 9 | 14 | def test_section_list(self): | |
u = User.objects.get(email="none@none.com") | 10 | 15 | section = Section.objects.get(course_num='101a') | |
u.sections.add(None) | 11 | 16 | user = User.objects.get(email="none@none.com") | |
17 | self.assertNotIn(section, user.sections.all()) | |||
18 | user.sections.add(section) | |||
19 | self.assertIn(section, user.sections.all()) | |||
20 | user.sections.add(section) | |||
21 | self.assertEqual(user.sections.count(), 1) | |||
12 | 22 |