def test_upload_form_in_details_if_perms(self): self.user.has_perm = mock.MagicMock(return_value=True) view = MapEntityDetail.as_view(model=DummyModel, template_name="mapentity/mapentity_detail.html") request = self.createRequest() response = view(request, pk=self.object.pk) html = unicode(response.render()) self.assertIn("Submit attachment", html) self.assertIn("""<form action="/paperclip/add-for/tests/dummymodel/1/""", html)
def test_upload_form_in_details_if_perms(self): self.user.has_perm = mock.MagicMock(return_value=True) view = MapEntityDetail.as_view( model=DummyModel, template_name="mapentity/mapentity_detail.html") request = self.createRequest() response = view(request, pk=self.object.pk) html = unicode(response.render()) self.assertIn("Submit attachment", html) self.assertIn( """<form action="/paperclip/add-for/tests/dummymodel/1/""", html)
def test_upload_form_in_details_if_perms(self): self.user.has_perm = mock.MagicMock(return_value=True) view = MapEntityDetail.as_view(model=DummyModel, template_name="mapentity/mapentity_detail.html") request = self.createRequest() response = view(request, pk=self.object.pk) html = unicode(response.render()) self.assertTrue("Upload attachment" in html) self.assertTrue("""<form method="post" enctype="multipart/form-data" action="/paperclip/add-for/tests/dummymodel/1/""" in html)
def test_upload_form_in_details_if_perms(self): self.user.has_perm = mock.MagicMock(return_value=True) view = MapEntityDetail.as_view( model=TouristicEvent, template_name="mapentity/mapentity_detail.html") request = self.createRequest() response = view(request, pk=self.object.pk) html = response.render() self.assertIn(b"Submit attachment", html.content) self.assertIn( '<form action="/paperclip/add-for/tourism/touristicevent/{}/'. format(self.object.pk).encode(), html.content)
def test_list_attachments_in_details(self): self.createAttachment(self.object) request = self.createRequest() view = MapEntityDetail.as_view(model=DummyModel, template_name="mapentity/mapentity_detail.html") response = view(request, pk=self.object.pk) html = unicode(response.render()) self.assertTemplateUsed(response, template_name='paperclip/attachment_list.html') self.assertEqual(1, len(Attachment.objects.attachments_for_object(self.object))) self.assertNotIn("Submit attachment", html) for attachment in Attachment.objects.attachments_for_object(self.object): self.assertIn(attachment.legend, html) self.assertIn(attachment.title, html) self.assertIn(attachment.attachment_file.url, html) self.assertIn('paperclip/fileicons/odt.png', html)
def test_list_attachments_in_details(self): self.createAttachment(self.object) request = self.createRequest() view = MapEntityDetail.as_view( model=DummyModel, template_name="mapentity/mapentity_detail.html") response = view(request, pk=self.object.pk) html = unicode(response.render()) self.assertTemplateUsed(response, template_name='paperclip/attachment_list.html') self.assertEqual( 1, len(Attachment.objects.attachments_for_object(self.object))) self.assertNotIn("Submit attachment", html) for attachment in Attachment.objects.attachments_for_object( self.object): self.assertIn(attachment.legend, html) self.assertIn(attachment.title, html) self.assertIn(attachment.attachment_file.url, html) self.assertIn('paperclip/fileicons/odt.png', html)