Ejemplo n.º 1
0
    def testListContainsOneSector(self):
        subject_sector = SubjectSector(number=100, name='Test Sector')
        subject_sector.save()

        response = self.client.get(reverse('misc:subject-sector:list'))
        self.assertContains(response, 'Test Sector')
        self.assertContains(response, '100')
Ejemplo n.º 2
0
    def testListContainsOneSector(self):
        subject_sector = SubjectSector(number=100, name='Test Sector')
        subject_sector.save()

        response = self.client.get(reverse('misc:subject-sector:list'))
        self.assertContains(response, 'Test Sector')
        self.assertContains(response, '100')
Ejemplo n.º 3
0
    def testUpdate(self):
        new_name = "Test Sector Two"

        subject_sector = SubjectSector(number=101, name='Test Sector One')
        subject_sector.save()
        update_response = self.client.post(
            reverse('misc:subject-sector:update',
                    kwargs={'pk': subject_sector.pk}),
            {'number': 101, 'name': new_name},
            follow=True)
        self.assertRedirects(
            update_response,
            reverse('misc:subject-sector:detail',
                    kwargs={'pk': subject_sector.pk})
        )

        self.assertContains(update_response, new_name)
Ejemplo n.º 4
0
    def testUpdate(self):
        new_name = "Test Sector Two"

        subject_sector = SubjectSector(number=101, name='Test Sector One')
        subject_sector.save()
        update_response = self.client.post(reverse(
            'misc:subject-sector:update', kwargs={'pk': subject_sector.pk}), {
                'number': 101,
                'name': new_name
            },
                                           follow=True)
        self.assertRedirects(
            update_response,
            reverse('misc:subject-sector:detail',
                    kwargs={'pk': subject_sector.pk}))

        self.assertContains(update_response, new_name)
Ejemplo n.º 5
0
 def testDelete(self):
     SubjectSector(number=102, name='Test Sector Two').save()
     subject_sector = SubjectSector.objects.get(number=102)
     subject_sector_url = reverse('misc:subject-sector:detail',
                                  kwargs={'pk': subject_sector.pk})
     delete_url = reverse('misc:subject-sector:delete',
                          kwargs={'pk': subject_sector.pk})
     response_confirm = self.client.get(delete_url)
     self.assertEquals(response_confirm.status_code, 200)
     response = self.client.post(delete_url, follow=True)
     self.assertRedirects(response, reverse('misc:subject-sector:list'))
     self.assertNotContains(response, subject_sector.name)
     self.assertNotContains(
         response, '<td><a href="' + subject_sector_url + '">' +
         str(subject_sector.number) + '</td>')
Ejemplo n.º 6
0
 def testStr(self):
     subject_sector = SubjectSector(number=150,
                                    name="Test One Fifty Zero Sector")
     self.assertEquals(str(subject_sector),
                       "Test One Fifty Zero Sector (150)")