test_correlation.py 627 B

1234567891011121314151617181920
  1. # Copyright © 2023 Ingram Micro Inc. All rights reserved.
  2. from importlib import import_module, reload
  3. from dj_cqrs.correlation import get_correlation_id
  4. def test_default_correlation():
  5. assert get_correlation_id(None, None, None, None) is None
  6. def test_custom_correlation(settings):
  7. previous_cqrs_settings = settings.CQRS
  8. settings.CQRS = {'master': {'correlation_function': lambda *args: '1q2w3e'}}
  9. reload(import_module('dj_cqrs.correlation'))
  10. assert get_correlation_id(None, None, None, None) == '1q2w3e'
  11. settings.CQRS = previous_cqrs_settings
  12. reload(import_module('dj_cqrs.correlation'))