Skip to content

Commit

Permalink
test: missing go dependency exception with default options
Browse files Browse the repository at this point in the history
  • Loading branch information
mrf345 committed Jul 14, 2024
1 parent 86aa603 commit d100773
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def setup(self):
self.bypass = []
self.bypass_caching = []
self.caching_limit = 1
self.parsers = {}
self.go = True
self.patch = mock.patch.multiple("flask_minify.main", request=self.mock_request)

self.patch.start()
Expand All @@ -76,6 +78,8 @@ def minify_defaults(self):
self.bypass,
self.bypass_caching,
self.caching_limit,
parsers=self.parsers,
go=self.go,
)

def test_request_falsy_endpoint(self):
Expand Down Expand Up @@ -127,6 +131,26 @@ def executer(self, content, **options):
with pytest.raises(FlaskMinifyException):
parser.minify(LESS_RAW, "style")

def test_default_parsers_when_go_enabled_and_dependancy_missing(self):
with mock.patch("flask_minify.parsers.minify_go", None):
parser = parsers.Parser(go=True)
assert parser.default_parsers == parser._default_parsers

def test_default_parsers_when_go_enabled_and_dependency_present(self):
with mock.patch("flask_minify.parsers.minify_go"):
parser = parsers.Parser(go=True)
assert parser.default_parsers == parser._go_default_parsers

def test_default_parsers_when_go_disabled_and_dependency_present(self):
with mock.patch("flask_minify.parsers.minify_go"):
parser = parsers.Parser(go=False)
assert parser.default_parsers == parser._default_parsers

def test_go_parsers_passed_with_go_enabled_and_dependency_missing_exception(self):
with mock.patch("flask_minify.parsers.minify_go", None):
with pytest.raises(FlaskMinifyException):
parsers.Parser(parsers=parsers.Parser._go_default_parsers, go=True)


class TestMemoryCache:
def setup(self):
Expand Down

0 comments on commit d100773

Please sign in to comment.