test_position_helper.py 798 B

12345678910111213141516171819202122232425262728293031323334
  1. from textwrap import dedent
  2. import pytest
  3. from core.utils.position_helper import get_position_map
  4. @pytest.fixture
  5. def prepare_example_positions_yaml(tmp_path, monkeypatch) -> str:
  6. monkeypatch.chdir(tmp_path)
  7. tmp_path.joinpath("example_positions.yaml").write_text(dedent(
  8. """\
  9. - first
  10. - second
  11. # - commented
  12. - third
  13. - 9999999999999
  14. - forth
  15. """))
  16. return str(tmp_path)
  17. def test_position_helper(prepare_example_positions_yaml):
  18. position_map = get_position_map(
  19. folder_path=prepare_example_positions_yaml,
  20. file_name='example_positions.yaml')
  21. assert len(position_map) == 4
  22. assert position_map == {
  23. 'first': 0,
  24. 'second': 1,
  25. 'third': 2,
  26. 'forth': 3,
  27. }