Commit c2666439094534b92beb4f05de2b31bf0683636a
1 parent
967471203f
Exists in
master
fixed up section list test error
Showing 1 changed file with 14 additions and 4 deletions Side-by-side Diff
flashcards/tests/test_models.py
View file @
c266643
1 | 1 | from django.test import TestCase |
2 | -from flashcards.models import User | |
2 | +from flashcards.models import User, Section | |
3 | 3 | |
4 | 4 | |
5 | 5 | class UserTests(TestCase): |
6 | 6 | def setUp(self): |
7 | - u = User.objects.create(email="none@none.com",password="1234") | |
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 | |
9 | 14 | def test_section_list(self): |
10 | - u = User.objects.get(email="none@none.com") | |
11 | - u.sections.add(None) | |
15 | + section = Section.objects.get(course_num='101a') | |
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) |