Skip to content

Commit

Permalink
Added tests for breadcrumbs
Browse files Browse the repository at this point in the history
Refs #1547
  • Loading branch information
bmispelon committed Jun 14, 2024
1 parent 51e9bdf commit fea8ac1
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions docs/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,10 @@ def setUpTestData(cls):
'<p>See <a class="reference internal" href="../../../ref/class-based-views/">'
'<span class="doc">Built-in class-based views API</span></a>.</p>\n</div>\n'
),
"breadcrumbs": [],
"breadcrumbs": [
{"path": "topics", "title": "Using Django"},
{"path": "topics/http", "title": "Handling HTTP requests"},
],
"parents": "topics http",
"slug": "generic-views",
"title": "Generic views",
Expand All @@ -436,7 +439,9 @@ def setUpTestData(cls):
'<a class="reference external" href="https://code.djangoproject.com/ticket/13560">bug</a> that\n'
"affected datetime form field widgets when localization was enabled.</p>\n</div>\n"
),
"breadcrumbs": [],
"breadcrumbs": [
{"path": "releases", "title": "Release notes"},
],
"parents": "releases",
"slug": "1.2.1",
"title": "Django 1.2.1 release notes",
Expand All @@ -455,7 +460,9 @@ def setUpTestData(cls):
'where <code class="docutils literal"><span class="pre">utils.http.is_safe_url()</span></code> crashes on bytestring URLs '
'(<a class="reference external" href="https://code.djangoproject.com/ticket/26308">#26308</a>).</p>\n</div>\n'
),
"breadcrumbs": [],
"breadcrumbs": [
{"path": "releases", "title": "Release notes"},
],
"parents": "releases",
"slug": "1.9.4",
"title": "Django 1.9.4 release notes",
Expand All @@ -473,7 +480,10 @@ def setUpTestData(cls):
'<p>Voir <a class="reference internal" href="../../../ref/class-based-views/">'
'<span class="doc">API des vues intégrées fondées sur les classes.</span></a>.</p>\n</div>\n'
),
"breadcrumbs": [],
"breadcrumbs": [
{"path": "topics", "title": "Using Django"},
{"path": "topics/http", "title": "Handling HTTP requests"},
],
"parents": "topics http",
"slug": "generic-views",
"title": "Vues génériques",
Expand All @@ -494,7 +504,9 @@ def setUpTestData(cls):
'<a class="reference external" href="https://code.djangoproject.com/ticket/13560">bug</a> that\n'
"affected datetime form field widgets when localization was enabled.</p>\n</div>\n"
),
"breadcrumbs": [],
"breadcrumbs": [
{"path": "releases", "title": "Release notes"},
],
"parents": "releases",
"slug": "1.2.1",
"title": "Notes de publication de Django 1.2.1",
Expand All @@ -514,7 +526,9 @@ def setUpTestData(cls):
'where <code class="docutils literal"><span class="pre">utils.http.is_safe_url()</span></code> crashes on bytestring URLs '
'(<a class="reference external" href="https://code.djangoproject.com/ticket/26308">#26308</a>).</p>\n</div>\n'
),
"breadcrumbs": [],
"breadcrumbs": [
{"path": "releases", "title": "Release notes"},
],
"parents": "releases",
"slug": "1.9.4",
"title": "Notes de publication de Django 1.9.4",
Expand Down Expand Up @@ -578,6 +592,20 @@ def test_multilingual_search(self):
def test_empty_search(self):
self.assertSequenceEqual(Document.objects.search("", self.release), [])

def test_search_breadcrumbs(self):
doc = (
Document.objects.filter(title="Generic views")
.search("generic", self.release)
.get()
)
self.assertEqual(
doc.breadcrumbs,
[
{"path": "topics", "title": "Using Django"},
{"path": "topics/http", "title": "Handling HTTP requests"},
],
)

def test_search_reset(self):
self.assertEqual(Document.objects.exclude(search=None).count(), 6)
self.assertEqual(Document.objects.search_reset(), 6)
Expand Down

0 comments on commit fea8ac1

Please sign in to comment.