mirror of
https://github.com/suitenumerique/django-lasuite
synced 2026-04-25 17:15:14 +02:00
Like we did for the malware_detection module, we want helpers allowing use to instantiate a backend without knowing in the code how to do it, just importing a module and the marketing service is ready to be used.
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
"""Test the marketing handler."""
|
|
|
|
import pytest
|
|
from django.core.exceptions import ImproperlyConfigured
|
|
|
|
from lasuite.marketing.backends.dummy import DummyBackend
|
|
from lasuite.marketing.handler import MarketingHandler
|
|
|
|
|
|
def test_marketing_handler_from_settings(settings):
|
|
"""Test the marketing handler from the settings."""
|
|
settings.LASUITE_MARKETING = {
|
|
"BACKEND": "lasuite.marketing.backends.dummy.DummyBackend",
|
|
}
|
|
handler = MarketingHandler()
|
|
assert isinstance(handler(), DummyBackend)
|
|
|
|
|
|
def test_marketing_handler_from_backend():
|
|
"""Test the marketing handler from the backend."""
|
|
handler = MarketingHandler(
|
|
backend={
|
|
"BACKEND": "lasuite.marketing.backends.dummy.DummyBackend",
|
|
}
|
|
)
|
|
assert isinstance(handler(), DummyBackend)
|
|
|
|
|
|
def test_marketing_backend_no_config(settings):
|
|
"""Test the marketing handler when no config set should raise an error."""
|
|
settings.LASUITE_MARKETING = None
|
|
handler = MarketingHandler()
|
|
with pytest.raises(ImproperlyConfigured):
|
|
handler()
|