fix(test): Fix test_never_render to get path as string, exclude PYC files from static downloads

This test code never actually tested the behaviour for two reasons:
- first, the page had an error which meant that a 500 Error page was returned (because `path` is not a string)
- second, every page contains the string "400" because it's contained in some of the icons.svg icons!

I also found a minor related bug in static_page.py, allowing people to download PYC files (pycache)
This commit is contained in:
Corentin Flr 2023-06-15 18:36:30 +02:00 committed by GitHub
parent 71bfafc6b2
commit bcdc483a13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -340,8 +340,9 @@ class TestWebsite(FrappeTestCase):
FILES_TO_SKIP = choices(list(WWW.glob("**/*.py*")), k=10)
for suffix in FILES_TO_SKIP:
content = get_response_content(suffix.relative_to(WWW))
self.assertIn("404", content)
path: str = suffix.relative_to(WWW).as_posix()
content = get_response_content(path)
self.assertIn("<title>Not Found</title>", content)
def test_metatags(self):
content = get_response_content("/_test/_test_metatags")

View file

@ -8,7 +8,7 @@ import frappe
from frappe.website.page_renderers.base_renderer import BaseRenderer
from frappe.website.utils import is_binary_file
UNSUPPORTED_STATIC_PAGE_TYPES = ("html", "md", "js", "xml", "css", "txt", "py", "json")
UNSUPPORTED_STATIC_PAGE_TYPES = ("html", "md", "js", "xml", "css", "txt", "py", "pyc", "json")
class StaticPage(BaseRenderer):