test_path_utils.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding:utf-8 -*-
  2. import os
  3. from dw_base.datax.path_utils import job_name_from_ini, json_output_path, log_path
  4. def test_job_name_from_ini_absolute():
  5. assert job_name_from_ini(
  6. '/home/bigdata/release/poyee-data-warehouse/tests/integration/datax/hive_import/app_user_cert_info.ini'
  7. ) == 'app_user_cert_info'
  8. def test_job_name_from_ini_relative():
  9. assert job_name_from_ini('jobs/raw/usr/xxx.ini') == 'xxx'
  10. def test_job_name_from_ini_no_ext():
  11. assert job_name_from_ini('xxx') == 'xxx'
  12. def test_json_output_path_flat():
  13. out = json_output_path(
  14. '/opt/release/poyee-data-warehouse',
  15. 'tests/integration/datax/hive_import/app_user_cert_info.ini',
  16. )
  17. assert os.path.normpath(out) == os.path.normpath(
  18. '/opt/release/poyee-data-warehouse/conf/datax-json/app_user_cert_info.json'
  19. )
  20. def test_log_path_template():
  21. out = log_path('/home/bigdata/log', 'datax', '20260422', 'app_user_cert_info')
  22. assert os.path.normpath(out) == os.path.normpath(
  23. '/home/bigdata/log/datax/20260422/app_user_cert_info.log'
  24. )