test_download.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import pytest
  2. @pytest.fixture
  3. def temp_domain_directories(tmp_path):
  4. """
  5. Sets up a temporary directory structure for domains and releases for testing.
  6. Parameters
  7. ----------
  8. tmp_path : pathlib.Path
  9. A pytest-provided temporary directory path.
  10. Returns
  11. -------
  12. dict
  13. A dictionary containing the paths to the `downloaded_data` directory,
  14. the specific domain directory, and a list of sorted release paths.
  15. """
  16. downloaded_data = tmp_path / "downloaded_data"
  17. downloaded_data.mkdir()
  18. domains = (
  19. "farm_gate_emissions_crops",
  20. "farm_gate_livestock",
  21. "farm_gate_agriculture_energy",
  22. "land_use_forests",
  23. "land_use_fires",
  24. "land_use_drained_organic_soils",
  25. "pre_post_agricultural_production",
  26. )
  27. domain_paths = []
  28. for domain in domains:
  29. domain_path = downloaded_data / domain
  30. domain_path.mkdir()
  31. domain_paths.append(domain_path)
  32. return {
  33. "downloaded_data": downloaded_data,
  34. "domain_paths": domain_paths,
  35. }