-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests duplicate title tags (#834)
- Loading branch information
1 parent
a3459b2
commit 018d052
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Integration tests for all titles in Reflex.""" | ||
|
||
from pathlib import Path | ||
from collections import Counter | ||
import sys | ||
import pytest | ||
|
||
sys.path.append(str(Path(__file__).resolve().parent.parent)) | ||
|
||
|
||
@pytest.fixture | ||
def routes_fixture(): | ||
from pcweb.pages import routes | ||
yield routes | ||
|
||
|
||
def test_unique_titles(routes_fixture): | ||
assert routes_fixture is not None | ||
|
||
titles = [] | ||
for route in routes_fixture: | ||
if hasattr(route, 'title'): | ||
titles.append(route.title) | ||
|
||
# Count occurrences of each title | ||
title_counts = Counter(titles) | ||
|
||
# Find duplicate titles | ||
duplicates = [title for title, count in title_counts.items() if count > 1] | ||
|
||
# Assert that there are no duplicates | ||
assert len(duplicates) == 0, f"Duplicate titles found: {duplicates}" | ||
|
||
print(f"Test passed. All {len(titles)} titles are unique.") | ||
|