def test_list_plugins_authenticated(self): response = self.client.get(reverse("plugins:plugins_list")) self.assertHttpStatus(response, 200) response_body = extract_page_body( response.content.decode(response.charset)).lower() self.assertIn("dummy plugin", response_body, msg=response_body)
def test_list_plugins_authenticated_superuser(self): self.user.is_superuser = True self.user.save() response = self.client.get(reverse("plugins:plugins_list")) self.assertHttpStatus(response, 200) response_body = extract_page_body( response.content.decode(response.charset)).lower() self.assertIn("example plugin", response_body, msg=response_body)
def test_view_detail_authenticated(self): response = self.client.get( reverse("plugins:plugin_detail", kwargs={"plugin": "dummy_plugin"})) self.assertHttpStatus(response, 200) response_body = extract_page_body( response.content.decode(response.charset)).lower() # plugin verbose name self.assertIn("dummy plugin", response_body, msg=response_body) # plugin description self.assertIn("for testing purposes only", response_body, msg=response_body)
def test_view_object_with_custom_link(self): customlink = CustomLink( content_type=ContentType.objects.get_for_model(Site), name="Test", text="FOO {{ obj.name }} BAR", target_url="http://example.com/?site={{ obj.slug }}", new_window=False, ) customlink.save() site = Site(name="Test Site", slug="test-site") site.save() response = self.client.get(site.get_absolute_url(), follow=True) self.assertEqual(response.status_code, 200) content = extract_page_body(response.content.decode(response.charset)) self.assertIn(f"FOO {site.name} BAR", content, content)