test_station.py 803 B

1234567891011121314151617181920212223242526272829303132333435
  1. import pytest
  2. from copy import deepcopy
  3. @pytest.fixture
  4. def station_data():
  5. js = {
  6. "code": "abdl",
  7. "height": 162.27803882118315,
  8. "status": "new",
  9. "location": {
  10. "lat": 53.68908284179442,
  11. "lon": 53.64383132493483
  12. },
  13. "xyz": [
  14. 2243908.9008,
  15. 3048443.7188,
  16. 5116457.9962
  17. ]
  18. }
  19. return js
  20. class TestStation:
  21. def test_creation(self):
  22. try:
  23. Station(**js)
  24. except Exception as e:
  25. pytest.fail(f"Failed with exception '{type(e)} - {e}'")
  26. for field in ["code", "height", "status", "location"]:
  27. js_copy = deepcopy(js)
  28. del js["location"]
  29. with pytest.raises(StationError):
  30. Station(**js)