Multitenant implementation with custom Domain, theme per vendor
This commit is contained in:
23
tests/unit/middleware/test_vendor_context.py
Normal file
23
tests/unit/middleware/test_vendor_context.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from requests.cookies import MockRequest
|
||||
|
||||
from middleware.vendor_context import VendorContextManager
|
||||
|
||||
|
||||
def test_custom_domain_detection():
|
||||
# Mock request with custom domain
|
||||
request = MockRequest(host="customdomain1.com")
|
||||
context = VendorContextManager.detect_vendor_context(request)
|
||||
assert context["detection_method"] == "custom_domain"
|
||||
assert context["domain"] == "customdomain1.com"
|
||||
|
||||
def test_subdomain_detection():
|
||||
request = MockRequest(host="vendor1.platform.com")
|
||||
context = VendorContextManager.detect_vendor_context(request)
|
||||
assert context["detection_method"] == "subdomain"
|
||||
assert context["subdomain"] == "vendor1"
|
||||
|
||||
def test_path_detection():
|
||||
request = MockRequest(host="localhost", path="/vendor/vendor1/")
|
||||
context = VendorContextManager.detect_vendor_context(request)
|
||||
assert context["detection_method"] == "path"
|
||||
assert context["subdomain"] == "vendor1"
|
||||
Reference in New Issue
Block a user