Skip to content

Commit

Permalink
Unit tests added for is_binary_file function in env file
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdul-Muqadim-Arbisoft committed Feb 22, 2024
1 parent e811c4e commit 75e031d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ def test_files_are_rendered(self) -> None:
def test_is_binary_file(self) -> None:
self.assertTrue(env.is_binary_file("/home/somefile.ico"))

def test_is_binary_file_with_text_extension(self) -> None:
self.assertFalse(env.is_binary_file("/home/script.js"))

def test_is_binary_file_with_unrecognized_extension(self) -> None:
self.assertFalse(env.is_binary_file("/home/unknown.extension"))

def test_is_binary_file_without_extension(self) -> None:
self.assertFalse(env.is_binary_file("/home/file"))

def test_find_os_path(self) -> None:
environment = env.JinjaEnvironment()
path = environment.find_os_path("local/docker-compose.yml")
Expand Down
12 changes: 11 additions & 1 deletion tutor/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@

TEMPLATES_ROOT = str(importlib_resources.files("tutor") / "templates")
VERSION_FILENAME = "version"
BIN_FILE_EXTENSIONS = [".ico", ".jpg", ".patch", ".png", ".ttf", ".woff", ".woff2"]
N_FILE_EXTENSIONS = [
".ico",
".jpg",
".otf",
".patch",
".png",
".ttf",
".webp",
".woff",
".woff2",
]
TEXT_MIME_TYPES = ["application/xml", "application/json"]
TEXT_FILE_EXTENSIONS = [".html", ".xml", ".json", ".css", ".js"]
JinjaFilter = t.Callable[..., t.Any]
Expand Down

0 comments on commit 75e031d

Please sign in to comment.