importing_pro_test.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from view.idl_folder_translation.pro2tapestry_conf import parse_pro_file, convert_pro_to_tapestry_config
  2. import pathlib as pl
  3. import textfsm
  4. import pandas as pd
  5. import tempfile
  6. def test_parsing_pro():
  7. """
  8. Testing parsing a .pro file
  9. """
  10. test_file = pl.Path("tests") / "test_files" / "pro_tests" / "grl_A_5803a.pro"
  11. pro_data_df = parse_pro_file(test_file)
  12. expected_csv = pl.Path("tests") / "test_files" / "pro_tests" / "grl_A_5803a_expected.csv"
  13. pro_data_temp_op = pl.Path(tempfile.gettempdir()) / "grl_A_5803_temp_out.csv"
  14. pro_data_df.to_csv(pro_data_temp_op)
  15. # this works for expected files saved from linux when tested on linux and windows, filecmp.cmp does not.
  16. # might have something to do line terminators
  17. with open(pro_data_temp_op) as fho:
  18. with open(expected_csv) as fhe:
  19. assert fho.read() == fhe.read()
  20. def test_converting_pro():
  21. """
  22. Testing converting a .pro file
  23. :return:
  24. """
  25. test_file = pl.Path("tests") / "test_files" / "pro_tests" / "grl_A_5803a.pro"
  26. test_op_yml = pl.Path(tempfile.gettempdir()) / "grl_A_5803_temp_out.yml"
  27. convert_pro_to_tapestry_config(
  28. output_yml_file=test_op_yml, input_pro_file=test_file, animal_tag="A_5803a", flags_to_override={})
  29. expected_yml = pl.Path("tests") / "test_files" / "pro_tests" / "grl_A_5803a_expected.yml"
  30. # this works for expected files saved from linux when tested on linux and windows, filecmp.cmp does not.
  31. # might have something to do line terminators
  32. with open(expected_yml) as fho:
  33. with open(test_op_yml) as fhe:
  34. assert fho.read() == fhe.read()
  35. if __name__ == '__main__':
  36. # test_parsing_pro()
  37. test_converting_pro()