Skip to content

Commit 079ac8e

Browse files
committed
isolated the error seen via a test
1 parent aa450b3 commit 079ac8e

File tree

1 file changed

+82
-4
lines changed

1 file changed

+82
-4
lines changed

tests/test_plugins.py

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ def setUp(self):
171171
draft_pagecontent_version = self.pagecontent_version.copy(self.superuser)
172172
self.draft_pagecontent = draft_pagecontent_version.content
173173

174+
def test_correct_versioning_state_published_snippet_and_page(self):
175+
"""
176+
If a page is published, the published snippet should be rendered
177+
"""
174178
# Add plugin to our published page!
175179
add_plugin(
176180
self.pagecontent.placeholders.get(slot="content"),
@@ -186,10 +190,6 @@ def setUp(self):
186190
snippet_grouper=self.draft_snippet.snippet_grouper,
187191
)
188192

189-
def test_correct_versioning_state_published_snippet_and_page(self):
190-
"""
191-
If a page is published, the published snippet should be rendered
192-
"""
193193
# Request for published page
194194
request_url = self.page.get_absolute_url(self.language)
195195
with self.login_user_context(self.superuser):
@@ -201,9 +201,87 @@ def test_correct_versioning_state_draft_snippet_and_page(self):
201201
"""
202202
If we have a draft, the draft snippet should be rendered.
203203
"""
204+
# Add plugin to our published page!
205+
add_plugin(
206+
self.pagecontent.placeholders.get(slot="content"),
207+
"SnippetPlugin",
208+
self.language,
209+
snippet_grouper=self.snippet.snippet_grouper,
210+
)
211+
# Add plugin to our draft page
212+
add_plugin(
213+
self.draft_pagecontent.placeholders.get(slot="content"),
214+
"SnippetPlugin",
215+
self.language,
216+
snippet_grouper=self.draft_snippet.snippet_grouper,
217+
)
218+
204219
# Request for draft page
205220
request_url = get_object_edit_url(self.draft_pagecontent, "en")
206221
with self.login_user_context(self.superuser):
207222
response = self.client.get(request_url)
208223

209224
self.assertContains(response, "<p>draft content</p>")
225+
226+
def test_draft_snippet_and_page_live_url_rendering(self):
227+
"""
228+
If a page is published with a draft snippet is created
229+
nothing should be rendered!
230+
"""
231+
snippet_grouper = SnippetGrouper.objects.create()
232+
snippet = Snippet.objects.create(
233+
name="plugin_snippet",
234+
html="<p>Draft snippet</p>",
235+
slug="plugin_snippet",
236+
snippet_grouper=snippet_grouper,
237+
)
238+
Version.objects.create(
239+
content=snippet,
240+
created_by=self.superuser,
241+
created=datetime.datetime.now()
242+
)
243+
244+
add_plugin(
245+
self.pagecontent.placeholders.get(slot="content"),
246+
"SnippetPlugin",
247+
self.language,
248+
snippet_grouper=snippet_grouper,
249+
)
250+
251+
request_url = self.page.get_absolute_url(self.language)
252+
with self.login_user_context(self.superuser):
253+
response = self.client.get(request_url)
254+
255+
self.assertContains(response, "<p>Draft snippet</p>")
256+
257+
def test_published_snippet_and_page_live_url_rendering(self):
258+
"""
259+
If a page is published with a published snippet is
260+
created the snippet should be rendered!
261+
"""
262+
snippet_grouper = SnippetGrouper.objects.create()
263+
snippet = Snippet.objects.create(
264+
name="plugin_snippet",
265+
html="<p>Published snippet</p>",
266+
slug="plugin_snippet",
267+
snippet_grouper=snippet_grouper,
268+
)
269+
snippet_version = Version.objects.create(
270+
content=snippet,
271+
created_by=self.superuser,
272+
created=datetime.datetime.now()
273+
)
274+
snippet_version.publish(user=self.superuser)
275+
276+
add_plugin(
277+
self.pagecontent.placeholders.get(slot="content"),
278+
"SnippetPlugin",
279+
self.language,
280+
snippet_grouper=snippet_grouper,
281+
)
282+
283+
request_url = self.page.get_absolute_url(self.language)
284+
with self.login_user_context(self.superuser):
285+
response = self.client.get(request_url)
286+
287+
self.assertContains(response, "<p>Published snippet</p>")

0 commit comments

Comments
 (0)