-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds
HTMXConfig
for plugin customization (#6)
* feat: adds `HTMXConfig` for plugin customization * fix: addss type annotation
- Loading branch information
Showing
5 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from litestar.config.app import AppConfig | ||
|
||
from litestar_htmx import HTMXConfig, HTMXPlugin, HTMXRequest | ||
|
||
pytestmark = pytest.mark.anyio | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"set_request_class_globally", | ||
(True, False), | ||
) | ||
def test_request_class(set_request_class_globally: bool) -> None: | ||
config = HTMXConfig(set_request_class_globally=set_request_class_globally) | ||
plugin = HTMXPlugin(config=config) | ||
app_config = plugin.on_app_init(AppConfig()) | ||
if set_request_class_globally: | ||
assert app_config.request_class == HTMXRequest | ||
else: | ||
assert app_config.request_class is None | ||
|
||
|
||
class CustomHTMXRequest(HTMXRequest): | ||
"""Extra functionality.""" | ||
|
||
|
||
def test_request_class_no_override() -> None: | ||
plugin = HTMXPlugin() | ||
app_config = plugin.on_app_init(AppConfig(request_class=CustomHTMXRequest)) | ||
assert app_config.request_class == CustomHTMXRequest |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.