list_name_detection_test.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. from view.python_core.flags import FlagsManager
  2. from common import get_example_data_root_path
  3. def check_list_name_detection(yml_name, animal, expected_list_name):
  4. flags = FlagsManager()
  5. flags.read_flags_from_yml(yml_name)
  6. flags.update_flags({"STG_ReportTag": animal})
  7. assert expected_list_name == flags.get_existing_lst_file()
  8. def test_FID_setting_only():
  9. """
  10. Testing finding existing list file for the case when only settings.xls files are present
  11. :return:
  12. """
  13. data_root = get_example_data_root_path()
  14. project_root = data_root / "LM_Till_only_FID"
  15. test_yml = str(project_root/ "usage_till.yml")
  16. animal = "LM_GC-FID_or22a_170816a"
  17. expected_list = str(project_root / "lists" / "LM_GC-FID_or22a_170816a.settings.xls")
  18. check_list_name_detection(yml_name=test_yml, animal=animal, expected_list_name=expected_list)
  19. def test_FID_LSTMixed():
  20. """
  21. Testing finding existing list file for the case when lst.xls and .lst files are present
  22. :return:
  23. """
  24. data_root = get_example_data_root_path()
  25. project_root = data_root / "HS_Till"
  26. test_yml = str(project_root / "usage_till.yml")
  27. animal = "HS_bee_PELM_180416b"
  28. expected_list = str(project_root / "IDLlist" / "HS_bee_PELM_180416b.lst.xls")
  29. check_list_name_detection(yml_name=test_yml, animal=animal, expected_list_name=expected_list)
  30. def test_FID_XLSMixed():
  31. """
  32. Testing finding existing list file for the case when lst.xls and .settings.xls files are present
  33. :return:
  34. """
  35. data_root = get_example_data_root_path()
  36. project_root = data_root / "Or47a_test"
  37. test_yml = str(project_root / "usage_till_test.yml")
  38. animal = "AL_190506a_or47a"
  39. expected_list = str(project_root / "02_SETTINGS" / "AL_190506a_or47a.lst.xls")
  40. check_list_name_detection(yml_name=test_yml, animal=animal, expected_list_name=expected_list)
  41. def test_FID_LSTXLS_only():
  42. """
  43. Testing finding existing list file for the case when only lst.xls files are present
  44. :return:
  45. """
  46. data_root = get_example_data_root_path()
  47. project_root = data_root / "SS_LSM"
  48. test_yml = str(project_root / "usage_lsm.yml")
  49. animal = "2019_08_15_locust_oregon green"
  50. expected_list = str(project_root / "Lists" / "2019_08_15_locust_oregon green.lst.xls")
  51. check_list_name_detection(yml_name=test_yml, animal=animal, expected_list_name=expected_list)
  52. if __name__ == '__main__':
  53. test_FID_setting_only()