55import pytest
66from bs4 import BeautifulSoup
77
8- from psc .resources import Example
8+ from psc .here import HERE
9+ from psc .resources import Example , Resources
910from psc .resources import Page
1011from psc .resources import get_body_content
1112from psc .resources import get_head_nodes
1213from psc .resources import get_resources
13- from psc .resources import get_sorted_examples
14+ from psc .resources import get_sorted_paths
1415from psc .resources import is_local
1516from psc .resources import tag_filter
1617
17-
1818IS_LOCAL = is_local ()
1919
2020
@@ -30,6 +30,11 @@ def head_soup() -> BeautifulSoup:
3030 return BeautifulSoup (head , "html5lib" )
3131
3232
33+ @pytest .fixture (scope = "module" )
34+ def resources () -> Resources :
35+ return get_resources ()
36+
37+
3338def test_tag_filter (head_soup : BeautifulSoup ) -> None :
3439 """Helper function to filter link and script from head."""
3540 excluded_link = head_soup .select ("link" )[0 ]
@@ -118,8 +123,8 @@ def test_example() -> None:
118123 this_example = Example (path = PurePath ("hello_world" ))
119124 assert this_example .title == "Hello World"
120125 assert (
121- this_example .subtitle
122- == "The classic hello world, but in Python -- in a browser!"
126+ this_example .subtitle
127+ == "The classic hello world, but in Python -- in a browser!"
123128 )
124129 assert "hello_world.css" in this_example .extra_head
125130 assert "<h1>Hello ...</h1>" in this_example .body
@@ -155,23 +160,29 @@ def test_missing_page() -> None:
155160
156161
157162def test_sorted_examples () -> None :
158- """Ensure a stable listing."""
159- examples = get_sorted_examples ( )
163+ """Ensure a stable listing of dirs ."""
164+ examples = get_sorted_paths ( HERE / "gallery/examples" )
160165 first_example = examples [0 ]
161166 assert "altair" == first_example .name
162167
163168
164- def test_get_resources () -> None :
169+ def test_sorted_authors () -> None :
170+ """Ensure a stable listing of files."""
171+ authors = get_sorted_paths (HERE / "gallery/authors" , only_dirs = False )
172+ first_author = authors [0 ]
173+ assert "meg-1.md" == first_author .name
174+
175+
176+ def test_get_resources (resources : Resources ) -> None :
165177 """Ensure the dict-of-dicts is generated with PurePath keys."""
166- resources = get_resources ()
167178
168179 # Example
169180 hello_world_path = PurePath ("hello_world" )
170181 hello_world = resources .examples [hello_world_path ]
171182 assert hello_world .title == "Hello World"
172183 assert (
173- hello_world .subtitle
174- == "The classic hello world, but in Python -- in a browser!"
184+ hello_world .subtitle
185+ == "The classic hello world, but in Python -- in a browser!"
175186 )
176187
177188 # Page
@@ -186,3 +197,10 @@ def test_is_local_broken_path() -> None:
186197 test_path = Path ("/xxx" )
187198 actual = is_local (test_path )
188199 assert not actual
200+
201+
202+ def test_authors (resources : Resources ) -> None :
203+ """Get the list of authors as defined in Markdown files."""
204+ authors = resources .authors
205+ first_author = list (authors .values ())[0 ]
206+ assert "meg-1" == first_author .path .name
0 commit comments