|
1 | 1 | """Construct the various kinds of resources: example, page, contributor.""" |
2 | | -from pathlib import PurePath |
| 2 | +from pathlib import PurePath, Path |
3 | 3 |
|
4 | 4 | import pytest |
5 | 5 | from bs4 import BeautifulSoup |
6 | 6 |
|
7 | | -from psc.resources import Example |
| 7 | +from psc.resources import Example, is_local |
8 | 8 | from psc.resources import Page |
9 | 9 | from psc.resources import get_body_content |
10 | 10 | from psc.resources import get_head_nodes |
@@ -72,8 +72,8 @@ def test_example() -> None: |
72 | 72 | this_example = Example(path=PurePath("hello_world")) |
73 | 73 | assert this_example.title == "Hello World" |
74 | 74 | assert ( |
75 | | - this_example.subtitle |
76 | | - == "The classic hello world, but in Python -- in a browser!" |
| 75 | + this_example.subtitle |
| 76 | + == "The classic hello world, but in Python -- in a browser!" |
77 | 77 | ) |
78 | 78 | assert "hello_world.css" in this_example.extra_head |
79 | 79 | assert "<h1>Hello ...</h1>" in this_example.body |
@@ -117,12 +117,25 @@ def test_get_resources() -> None: |
117 | 117 | hello_world = resources.examples[hello_world_path] |
118 | 118 | assert hello_world.title == "Hello World" |
119 | 119 | assert ( |
120 | | - hello_world.subtitle |
121 | | - == "The classic hello world, but in Python -- in a browser!" |
| 120 | + hello_world.subtitle |
| 121 | + == "The classic hello world, but in Python -- in a browser!" |
122 | 122 | ) |
123 | 123 |
|
124 | 124 | # Page |
125 | 125 | about_path = PurePath("about") |
126 | 126 | about = resources.pages[about_path] |
127 | 127 | assert about.title == "About the PyScript Collective" |
128 | 128 | assert "<h1>Helping" in about.body |
| 129 | + |
| 130 | + |
| 131 | +def test_is_local_no_path() -> None: |
| 132 | + """Test the local case where a directory exists.""" |
| 133 | + actual = is_local() |
| 134 | + assert actual |
| 135 | + |
| 136 | + |
| 137 | +def test_is_local_broken_path() -> None: |
| 138 | + """Test the local case where a directory will not exist.""" |
| 139 | + test_path = Path("/xxxxxx") |
| 140 | + actual = is_local(test_path) |
| 141 | + assert not actual |
0 commit comments