Ticket #12749: tests.py

File tests.py, 1.1 KB (added by Natalia Bidart, 15 years ago)
Line 
1from django.test import TestCase
2from models import Person, OutfitItem, Fashionista
3
4class AdminTest(TestCase):
5 fixtures = ['initial.json']
6
7 def setUp(self):
8 Person(firstname='test person').save()
9 OutfitItem(name='something').save()
10 self.client.login(username='super', password='secret')
11
12 def tearDown(self):
13 self.client.logout()
14
15 def test_inline_primary(self):
16 #Imelda likes shoes, but can't cary her own bags.
17 data = {
18 'shoppingweakness_set-TOTAL_FORMS': 1,
19 'shoppingweakness_set-INITIAL_FORMS': 0,
20 'shoppingweakness_set-MAX_NUM_FORMS': 0,
21 '_save': u'Save',
22 'person': 1,
23 'max_weight': 0,
24 'shoppingweakness_set-0-item': 1,
25 'shoppingweakness_set-0-severeness': 100
26 }
27 response = self.client.post('/admin/primary_key_inline/fashionista/add/', data)
28 errors = response.context['errors']
29 for error in errors:
30 self.assertContains(response, errors)
31 self.assertEqual(len(Fashionista.objects.filter(person__firstname='Imelda')), 1)
Back to Top