Skip to content

Commit a56febf

Browse files
committed
Add docs about removing the download cache
1 parent bc17f5b commit a56febf

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

tests/test_downloader.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
PORT = 8181
1414

15+
# if any changes are needed in the files served out of the "samples" folder, you need to delete the .webcache folder
16+
# that is generated at the project root for the tests to be rerun
1517
@pytest.fixture(scope="module")
1618
def http_local_server():
1719
# Get the directory containing the current file
@@ -26,6 +28,10 @@ def __init__(self, *args, **kwargs):
2628

2729
def spawn_http_server(arg):
2830
with http.server.HTTPServer(("", PORT), Handler) as httpd:
31+
# this is a behavior to treat extensionless files as CSS is used by
32+
# the test test_pretextbook_css_fetch below, see the docs on that test
33+
# method for more info
34+
Handler.extensions_map = {'': 'text/css'}
2935
print("serving at port", PORT)
3036
try:
3137
httpd.serve_forever()
@@ -106,6 +112,14 @@ def test_archive_path_as_relative_url(self):
106112
)
107113
assert rel_path == "../kolibri_1.2.3.png"
108114

115+
# If any changes are needed in the files served out of the "samples" folder, you need to delete the .webcache folder
116+
# that is generated at the project root for the tests to be rerun
117+
#
118+
# This test relies on behavior in the embedded http server declared above as a class level fixture
119+
# to treat any extensionless file as having a mime type of text/css.
120+
# Handler.extensions_map = {'': 'text/css'}
121+
# if another test needs different behavior this may need to be customized or have the fixture be scoped to this test
122+
# but for now it seems useful to share the resource between this and other future tests.
109123
def test_pretextbook_css_fetch(self):
110124
sushi_url = "http://localhost:" + str(PORT) + "/samples/PreTeXt_book_test/activecalculus.org/single2e/sec-5-2-FTC2.html"
111125
dest_dir = "active_calc_2e_again_" + datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
@@ -118,13 +132,15 @@ def test_pretextbook_css_fetch(self):
118132
book_dest_dir = downloads_dir / dest_dir / "localhost:8181" / "samples" / "PreTeXt_book_test"
119133
with open(book_dest_dir / "activecalculus.org" / "single2e" / "sec-5-2-FTC2.html", 'r') as file:
120134
page_html = file.read()
121-
assert "link href=\"../../fonts.googleapis.com/css2_family" in page_html
135+
assert "link href=\"../../fonts.googleapis.com/css2_family_Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0/index.css" in page_html
122136

123137
with open(book_dest_dir / "fonts.googleapis.com" / "css2_family_Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" / "index.css", 'r') as file:
124138
css_file_contents = file.read()
139+
# this has an extra '..' compared to what is in the original extensionless css file, because in the course of generating an index.css
140+
# file to have clear extensions in the archived version the file ends up nested down another level
125141
assert "src: url(\"../../fonts.gstatic.com/s/materialsymbolsoutlined" in css_file_contents
126142

127-
font_size = os.path.getsize(book_dest_dir / "fonts.gstatic.com" / "s" / "materialsymbolsoutlined" / "v290" / "kJF1BvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oDMzByHX9rA6RzaxHMPdY43zj-jCxv3fzvRNU22ZXGJpEpjC_1v-p_4MrImHCIJIZrDCvHOel.woff")
143+
font_size = os.path.getsize(book_dest_dir / "fonts.gstatic.com" / "s" / "materialsymbolsoutlined" / "v290" / "material_symbols.woff")
128144
assert font_size > 0
129145
finally:
130146
shutil.rmtree(downloads_dir / dest_dir)

tests/testcontent/samples/PreTeXt_book_test/activecalculus.org/single2e/sec-5-2-FTC2.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
</title>
1313
<link href="" rel="preconnect"/>
1414
<link crossorigin="sec-5-2-FTC2.html" href="" rel="preconnect"/>
15-
<link href="../../fonts.googleapis.com/css2_family_Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0/index.css" rel="stylesheet"/>
15+
<link href="../../fonts.googleapis.com/css2_family_Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" rel="stylesheet"/>
1616
</head>
1717
<body class="pretext book ignore-math">
1818
<span aria-hidden="true" class="icon material-symbols-outlined">
1919
2020
</span>
2121
</body>
22-
</html>
22+
</html>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
font-family: 'Material Symbols Outlined';
33
font-style: normal;
44
font-weight: 400;
5-
src: url("../../fonts.gstatic.com/s/materialsymbolsoutlined/v290/kJF1BvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oDMzByHX9rA6RzaxHMPdY43zj-jCxv3fzvRNU22ZXGJpEpjC_1v-p_4MrImHCIJIZrDCvHOel.woff") format('woff');
5+
src: url("../fonts.gstatic.com/s/materialsymbolsoutlined/v290/material_symbols.woff") format('woff');
66
}
77

88
.material-symbols-outlined {

0 commit comments

Comments
 (0)