Ejemplo n.º 1
0
 def test_list(self):
     transporter = TransporterFactory()
     rsp = self.client.get(reverse('transporter_list'))
     self.assertEqual(200, rsp.status_code)
     self.assertContains(rsp,
                         transporter.name,
                         msg_prefix=rsp.content.decode('utf-8'))
Ejemplo n.º 2
0
 def test_delete(self):
     # Delete a transporter
     transporter = TransporterFactory()
     url = reverse('transporter_delete', args=[transporter.pk])
     rsp = self.client.get(url)
     self.assertEqual(200, rsp.status_code)
     self.assertContains(rsp, 'Confirm')
     Transporter.objects.get(pk=transporter.pk)
     # Now delete it!
     rsp = self.client.post(url)
     if rsp.status_code == 400:
         self.fail(rsp.context['form'].errors)
     self.assertRedirects(rsp, reverse('transporter_list'))
     self.assertFalse(
         Transporter.objects.filter(pk=transporter.pk).exists())
Ejemplo n.º 3
0
 def test_update(self):
     # Update a transporter
     transporter = TransporterFactory()
     url = reverse('edit_transporter_modal', args=[transporter.pk])
     rsp = self.client.get(url)
     self.assertEqual(200, rsp.status_code)
     # Submit the new object
     name = "edited"
     data = {
         'name': name,
     }
     rsp = self.client.post(url, data=data)
     if rsp.status_code == 400:
         self.fail(rsp.context['form'].errors)
     self.assertEqual(rsp.status_code, 200)
     transporter2 = Transporter.objects.get(name=name)
     self.assertEqual(transporter.pk, transporter2.pk)
Ejemplo n.º 4
0
 def test_edit_modal(self):
     transporter = TransporterFactory()
     url = reverse('edit_transporter_modal', kwargs={'pk': transporter.pk})
     rsp = self.client.get(url)
     self.assertEqual(200, rsp.status_code)
     self.assertTemplateUsed(rsp, 'catalog/transporter_edit_modal.html')