hestia-earth-models 0.67.0__py3-none-any.whl → 0.68.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hestia_earth/models/aware/scarcityWeightedWaterUse.py +5 -6
- hestia_earth/models/blonkConsultants2016/ch4ToAirNaturalVegetationBurning.py +1 -1
- hestia_earth/models/blonkConsultants2016/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +1 -1
- hestia_earth/models/blonkConsultants2016/n2OToAirNaturalVegetationBurningDirect.py +1 -1
- hestia_earth/models/blonkConsultants2016/utils.py +9 -9
- hestia_earth/models/cache_sites.py +26 -14
- hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandOccupation.py +2 -2
- hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandTransformation.py +2 -2
- hestia_earth/models/chaudharyBrooks2018/utils.py +13 -8
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +2 -3
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionMineralsAndMetals.py +1 -1
- hestia_earth/models/cml2001Baseline/resourceUseEnergyDepletionDuringCycle.py +5 -10
- hestia_earth/models/config/Cycle.json +15 -0
- hestia_earth/models/config/ImpactAssessment.json +14 -1
- hestia_earth/models/config/Site.json +8 -0
- hestia_earth/models/cycle/completeness/freshForage.py +7 -3
- hestia_earth/models/cycle/excretaKgMass.py +2 -2
- hestia_earth/models/cycle/inorganicFertiliser.py +67 -17
- hestia_earth/models/cycle/materialAndSubstrate.py +3 -2
- hestia_earth/models/cycle/pastureGrass.py +3 -3
- hestia_earth/models/dammgen2009/noxToAirExcreta.py +1 -1
- hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py +1 -1
- hestia_earth/models/ecoinventV3AndEmberClimate/utils.py +2 -6
- hestia_earth/models/emissionNotRelevant/__init__.py +4 -4
- hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +60 -46
- hestia_earth/models/environmentalFootprintV3_1/photochemicalOzoneCreationPotentialHumanHealthNmvocEq.py +36 -0
- hestia_earth/models/environmentalFootprintV3_1/scarcityWeightedWaterUse.py +2 -2
- hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandOccupation.py +9 -8
- hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandTransformation.py +45 -34
- hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexTotalLandUseEffects.py +24 -21
- hestia_earth/models/faostat2018/coldCarcassWeightPerHead.py +2 -2
- hestia_earth/models/faostat2018/coldDressedCarcassWeightPerHead.py +2 -2
- hestia_earth/models/faostat2018/liveweightPerHead.py +7 -8
- hestia_earth/models/faostat2018/product/price.py +34 -28
- hestia_earth/models/faostat2018/readyToCookWeightPerHead.py +2 -2
- hestia_earth/models/faostat2018/utils.py +15 -27
- hestia_earth/models/frischknechtEtAl2000/ionisingRadiationKbqU235Eq.py +16 -9
- hestia_earth/models/geospatialDatabase/altitude.py +60 -0
- hestia_earth/models/geospatialDatabase/croppingIntensity.py +1 -1
- hestia_earth/models/geospatialDatabase/ecoClimateZone.py +2 -2
- hestia_earth/models/geospatialDatabase/longFallowRatio.py +1 -1
- hestia_earth/models/geospatialDatabase/utils.py +4 -1
- hestia_earth/models/globalCropWaterModel2008/rootingDepth.py +2 -3
- hestia_earth/models/haversineFormula/transport/distance.py +3 -3
- hestia_earth/models/hestia/landCover.py +72 -45
- hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py +1 -1
- hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py +1 -1
- hestia_earth/models/hestia/seed_emissions.py +11 -7
- hestia_earth/models/impact_assessment/__init__.py +3 -3
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +1 -1
- hestia_earth/models/ipcc2019/animal/fatContent.py +1 -1
- hestia_earth/models/ipcc2019/animal/hoursWorkedPerDay.py +1 -1
- hestia_earth/models/ipcc2019/animal/liveweightGain.py +1 -1
- hestia_earth/models/ipcc2019/animal/liveweightPerHead.py +1 -1
- hestia_earth/models/ipcc2019/animal/milkYieldPerAnimal.py +1 -1
- hestia_earth/models/ipcc2019/animal/pastureGrass.py +1 -1
- hestia_earth/models/ipcc2019/animal/pregnancyRateTotal.py +1 -1
- hestia_earth/models/ipcc2019/animal/trueProteinContent.py +1 -1
- hestia_earth/models/ipcc2019/animal/utils.py +5 -7
- hestia_earth/models/ipcc2019/animal/weightAtMaturity.py +1 -1
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +1 -1
- hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py +2 -2
- hestia_earth/models/ipcc2019/ch4ToAirExcreta.py +6 -7
- hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py +5 -3
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +1 -1
- hestia_earth/models/ipcc2019/croppingDuration.py +3 -6
- hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +947 -0
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py +4 -4
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py +1 -1
- hestia_earth/models/ipcc2019/pastureGrass.py +1 -1
- hestia_earth/models/koble2014/residueBurnt.py +5 -7
- hestia_earth/models/koble2014/residueRemoved.py +5 -7
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/log.py +1 -1
- hestia_earth/models/mocking/search-results.json +3477 -1045
- hestia_earth/models/site/management.py +1 -1
- hestia_earth/models/site/post_checks/__init__.py +3 -2
- hestia_earth/models/site/post_checks/country.py +9 -0
- hestia_earth/models/site/pre_checks/__init__.py +3 -2
- hestia_earth/models/site/pre_checks/country.py +9 -0
- hestia_earth/models/utils/__init__.py +1 -16
- hestia_earth/models/utils/blank_node.py +89 -36
- hestia_earth/models/utils/completeness.py +3 -2
- hestia_earth/models/utils/cycle.py +5 -4
- hestia_earth/models/utils/ecoClimateZone.py +2 -2
- hestia_earth/models/utils/emission.py +5 -5
- hestia_earth/models/utils/feedipedia.py +6 -6
- hestia_earth/models/utils/impact_assessment.py +6 -6
- hestia_earth/models/utils/indicator.py +9 -7
- hestia_earth/models/utils/inorganicFertiliser.py +4 -6
- hestia_earth/models/utils/input.py +6 -5
- hestia_earth/models/utils/lookup.py +35 -105
- hestia_earth/models/utils/management.py +4 -4
- hestia_earth/models/utils/measurement.py +6 -7
- hestia_earth/models/utils/method.py +20 -0
- hestia_earth/models/utils/practice.py +4 -5
- hestia_earth/models/utils/product.py +4 -5
- hestia_earth/models/utils/property.py +12 -22
- hestia_earth/models/utils/site.py +14 -8
- hestia_earth/models/utils/term.py +27 -1
- hestia_earth/models/version.py +1 -1
- hestia_earth/orchestrator/log.py +0 -11
- hestia_earth/orchestrator/models/__init__.py +17 -4
- hestia_earth/orchestrator/strategies/run/add_blank_node_if_missing.py +2 -20
- {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/RECORD +159 -151
- tests/models/cml2001Baseline/test_abioticResourceDepletionFossilFuels.py +3 -3
- tests/models/cml2001Baseline/test_resourceUseEnergyDepletionDuringCycle.py +68 -35
- tests/models/cycle/test_coldCarcassWeightPerHead.py +1 -1
- tests/models/cycle/test_coldDressedCarcassWeightPerHead.py +1 -1
- tests/models/cycle/test_concentrateFeed.py +1 -1
- tests/models/cycle/test_energyContentLowerHeatingValue.py +1 -1
- tests/models/cycle/test_excretaKgMass.py +1 -1
- tests/models/cycle/test_feedConversionRatio.py +3 -3
- tests/models/cycle/test_pastureGrass.py +1 -1
- tests/models/cycle/test_readyToCookWeightPerHead.py +1 -1
- tests/models/environmentalFootprintV3_1/test_environmentalFootprintSingleOverallScore.py +38 -8
- tests/models/environmentalFootprintV3_1/test_photochemicalOzoneCreationPotentialHumanHealthNmvocEq.py +30 -0
- tests/models/environmentalFootprintV3_1/test_soilQualityIndexLandTransformation.py +65 -36
- tests/models/environmentalFootprintV3_1/test_soilQualityIndexTotalLandUseEffects.py +30 -7
- tests/models/faostat2018/product/test_price.py +27 -14
- tests/models/faostat2018/test_faostat_utils.py +4 -24
- tests/models/faostat2018/test_liveweightPerHead.py +9 -9
- tests/models/globalCropWaterModel2008/test_rootingDepth.py +7 -3
- tests/models/haversineFormula/transport/test_distance.py +1 -1
- tests/models/hestia/test_landCover.py +53 -5
- tests/models/ipcc2019/animal/test_pastureGrass.py +5 -3
- tests/models/ipcc2019/test_aboveGroundCropResidueTotal.py +4 -4
- tests/models/ipcc2019/test_belowGroundCropResidue.py +4 -4
- tests/models/ipcc2019/test_ch4ToAirEntericFermentation.py +10 -10
- tests/models/ipcc2019/test_croppingDuration.py +1 -1
- tests/models/ipcc2019/test_nonCo2EmissionsToAirNaturalVegetationBurning.py +83 -0
- tests/models/ipcc2019/test_organicCarbonPerHa.py +12 -12
- tests/models/ipcc2019/test_pastureGrass.py +5 -3
- tests/models/pooreNemecek2018/test_excretaKgN.py +5 -5
- tests/models/pooreNemecek2018/test_excretaKgVs.py +2 -2
- tests/models/site/post_checks/test_country.py +6 -0
- tests/models/site/pre_checks/test_cache_geospatialDatabase.py +1 -1
- tests/models/site/pre_checks/test_country.py +12 -0
- tests/models/site/test_management.py +1 -4
- tests/models/test_ecoinventV3.py +7 -3
- tests/models/utils/test_blank_node.py +17 -177
- tests/models/utils/test_dataCompleteness.py +5 -5
- tests/models/utils/test_emission.py +2 -2
- tests/models/utils/test_indicator.py +2 -2
- tests/models/utils/test_input.py +2 -2
- tests/models/utils/test_measurement.py +2 -4
- tests/models/utils/test_practice.py +4 -2
- tests/models/utils/test_product.py +2 -2
- tests/models/utils/test_property.py +4 -2
- tests/models/utils/test_site.py +7 -0
- tests/orchestrator/models/test_transformations.py +4 -1
- tests/orchestrator/strategies/run/test_add_blank_node_if_missing.py +4 -9
- hestia_earth/models/environmentalFootprintV3_1/utils.py +0 -17
- tests/models/utils/test_lookup.py +0 -10
- {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/top_level.txt +0 -0
@@ -9,12 +9,13 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/product/{MODEL_KEY}"
|
|
9
9
|
|
10
10
|
|
11
11
|
def test_lookup_data():
|
12
|
-
|
12
|
+
country = {'@id': 'GADM-GHA'}
|
13
|
+
assert _lookup_data('cocoaSeedDehulled', 'Cocoa beans', country, 2000, term_type='crop') == 412.9
|
13
14
|
# average price per tonne as year value is missing
|
14
|
-
assert _lookup_data('cocoaSeedDehulled', 'Cocoa beans',
|
15
|
+
assert _lookup_data('cocoaSeedDehulled', 'Cocoa beans', country, 2012, term_type='crop') == 844.0571428571428
|
15
16
|
|
16
17
|
|
17
|
-
@patch(f"{class_path}.
|
18
|
+
@patch(f"{class_path}.download_term", return_value={})
|
18
19
|
def test_run_crop(*args):
|
19
20
|
with open(f"{fixtures_folder}/crop/cycle.jsonld", encoding='utf-8') as f:
|
20
21
|
cycle = json.load(f)
|
@@ -26,7 +27,19 @@ def test_run_crop(*args):
|
|
26
27
|
assert value == expected
|
27
28
|
|
28
29
|
|
29
|
-
@patch(f"{class_path}.
|
30
|
+
@patch(f"{class_path}.download_term", return_value={})
|
31
|
+
def test_run_missing_country_price(*args):
|
32
|
+
with open(f"{fixtures_folder}/missing-country-price/cycle.jsonld", encoding='utf-8') as f:
|
33
|
+
cycle = json.load(f)
|
34
|
+
|
35
|
+
with open(f"{fixtures_folder}/missing-country-price/result.jsonld", encoding='utf-8') as f:
|
36
|
+
expected = json.load(f)
|
37
|
+
|
38
|
+
value = run(cycle)
|
39
|
+
assert value == expected
|
40
|
+
|
41
|
+
|
42
|
+
@patch(f"{class_path}.download_term", return_value={})
|
30
43
|
def test_run_animalProduct_kg(*args):
|
31
44
|
with open(f"{fixtures_folder}/animalProduct/kg/cycle.jsonld", encoding='utf-8') as f:
|
32
45
|
cycle = json.load(f)
|
@@ -38,7 +51,7 @@ def test_run_animalProduct_kg(*args):
|
|
38
51
|
assert value == expected
|
39
52
|
|
40
53
|
|
41
|
-
@patch(f"{class_path}.
|
54
|
+
@patch(f"{class_path}.download_term", return_value={})
|
42
55
|
def test_run_animalProduct_number(*args):
|
43
56
|
with open(f"{fixtures_folder}/animalProduct/number/cycle.jsonld", encoding='utf-8') as f:
|
44
57
|
cycle = json.load(f)
|
@@ -50,15 +63,15 @@ def test_run_animalProduct_number(*args):
|
|
50
63
|
assert value == expected
|
51
64
|
|
52
65
|
|
53
|
-
@patch(f"{class_path}.
|
54
|
-
def test_run_liveAnimal_chicken(
|
66
|
+
@patch(f"{class_path}.download_term")
|
67
|
+
def test_run_liveAnimal_chicken(mock_download_term):
|
55
68
|
with open(f"{fixtures_folder}/liveAnimal/chicken/cycle.jsonld", encoding='utf-8') as f:
|
56
69
|
cycle = json.load(f)
|
57
70
|
|
58
71
|
with open(f"{fixtures_folder}/liveAnimal/chicken/result.jsonld", encoding='utf-8') as f:
|
59
72
|
expected = json.load(f)
|
60
73
|
|
61
|
-
|
74
|
+
mock_download_term.return_value = {
|
62
75
|
"@id": "meatChickenLiveweight",
|
63
76
|
"@type": "Term",
|
64
77
|
"units": "kg liveweight",
|
@@ -68,15 +81,15 @@ def test_run_liveAnimal_chicken(mock_download_hestia):
|
|
68
81
|
assert value == expected
|
69
82
|
|
70
83
|
|
71
|
-
@patch(f"{class_path}.
|
72
|
-
def test_run_liveAnimal_pig(
|
84
|
+
@patch(f"{class_path}.download_term")
|
85
|
+
def test_run_liveAnimal_pig(mock_download_term):
|
73
86
|
with open(f"{fixtures_folder}/liveAnimal/pig/cycle.jsonld", encoding='utf-8') as f:
|
74
87
|
cycle = json.load(f)
|
75
88
|
|
76
89
|
with open(f"{fixtures_folder}/liveAnimal/pig/result.jsonld", encoding='utf-8') as f:
|
77
90
|
expected = json.load(f)
|
78
91
|
|
79
|
-
|
92
|
+
mock_download_term.return_value = {
|
80
93
|
"@id": "meatPigLiveweight",
|
81
94
|
"@type": "Term",
|
82
95
|
"units": "kg liveweight",
|
@@ -86,15 +99,15 @@ def test_run_liveAnimal_pig(mock_download_hestia):
|
|
86
99
|
assert value == expected
|
87
100
|
|
88
101
|
|
89
|
-
@patch(f"{class_path}.
|
90
|
-
def test_run_liveAnimal_sheepLamb(
|
102
|
+
@patch(f"{class_path}.download_term")
|
103
|
+
def test_run_liveAnimal_sheepLamb(mock_download_term):
|
91
104
|
with open(f"{fixtures_folder}/liveAnimal/sheepLamb/cycle.jsonld", encoding='utf-8') as f:
|
92
105
|
cycle = json.load(f)
|
93
106
|
|
94
107
|
with open(f"{fixtures_folder}/liveAnimal/sheepLamb/result.jsonld", encoding='utf-8') as f:
|
95
108
|
expected = json.load(f)
|
96
109
|
|
97
|
-
|
110
|
+
mock_download_term.return_value = {
|
98
111
|
"@id": "meatSheepLiveweight",
|
99
112
|
"@type": "Term",
|
100
113
|
"units": "kg liveweight",
|
@@ -1,30 +1,14 @@
|
|
1
|
-
from
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
from hestia_earth.models.faostat2018.utils import (get_sum_of_columns, MODEL, get_land_ratio,
|
6
|
-
get_change_in_harvested_area_for_crop)
|
1
|
+
from hestia_earth.models.faostat2018.utils import (
|
2
|
+
MODEL, get_sum_of_columns, get_land_ratio, get_change_in_harvested_area_for_crop
|
3
|
+
)
|
7
4
|
from tests.utils import fixtures_path
|
8
5
|
|
9
6
|
CLASS_PATH = f"hestia_earth.models.{MODEL}.utils"
|
10
7
|
fixtures_folder = f"{fixtures_path}/{MODEL}/utils"
|
11
8
|
|
12
9
|
|
13
|
-
def _afg_download_fixture():
|
14
|
-
with open(f"{fixtures_folder}/gadm-afg.csv") as f:
|
15
|
-
afg_lookup = numpy.recfromcsv(
|
16
|
-
fname=f,
|
17
|
-
missing_values="",
|
18
|
-
filling_values="",
|
19
|
-
delimiter=",",
|
20
|
-
encoding="utf-8"
|
21
|
-
)
|
22
|
-
return afg_lookup
|
23
|
-
|
24
|
-
|
25
10
|
def test_get_sum_of_columns():
|
26
11
|
result = get_sum_of_columns(
|
27
|
-
lookup=_afg_download_fixture(),
|
28
12
|
country="GADM-AFG",
|
29
13
|
year=1975,
|
30
14
|
columns_list=["Arable land", "Permanent crops"]
|
@@ -38,14 +22,12 @@ def test_check_sums_for_columns():
|
|
38
22
|
"""
|
39
23
|
for year in range(1961, 2021):
|
40
24
|
sum_arab_perm = get_sum_of_columns(
|
41
|
-
lookup=_afg_download_fixture(),
|
42
25
|
country="GADM-AFG",
|
43
26
|
year=year,
|
44
27
|
columns_list=["Arable land", "Permanent crops"]
|
45
28
|
)
|
46
29
|
|
47
30
|
cropland_value = get_sum_of_columns(
|
48
|
-
lookup=_afg_download_fixture(),
|
49
31
|
country="GADM-AFG",
|
50
32
|
year=year,
|
51
33
|
columns_list=["Cropland"]
|
@@ -53,9 +35,7 @@ def test_check_sums_for_columns():
|
|
53
35
|
assert sum_arab_perm == cropland_value
|
54
36
|
|
55
37
|
|
56
|
-
|
57
|
-
def test_get_land_ratio(mock_lookup):
|
58
|
-
mock_lookup.return_value = _afg_download_fixture()
|
38
|
+
def test_get_land_ratio():
|
59
39
|
result = get_land_ratio(
|
60
40
|
country="GADM-AFG",
|
61
41
|
start_year=1990,
|
@@ -22,15 +22,15 @@ def test_run_animalProduct(*args):
|
|
22
22
|
|
23
23
|
|
24
24
|
@patch(f"{class_path}._new_property", side_effect=fake_new_property)
|
25
|
-
@patch(f"{class_path}.
|
26
|
-
def test_run_liveAnimal_chicken(
|
25
|
+
@patch(f"{class_path}.download_term")
|
26
|
+
def test_run_liveAnimal_chicken(mock_download_term, *args):
|
27
27
|
with open(f"{fixtures_folder}/liveAnimal/chicken/cycle.jsonld", encoding='utf-8') as f:
|
28
28
|
cycle = json.load(f)
|
29
29
|
|
30
30
|
with open(f"{fixtures_folder}/liveAnimal/chicken/result.jsonld", encoding='utf-8') as f:
|
31
31
|
expected = json.load(f)
|
32
32
|
|
33
|
-
|
33
|
+
mock_download_term.return_value = {
|
34
34
|
"@id": "meatChickenReadyToCookWeight",
|
35
35
|
"@type": "Term",
|
36
36
|
"units": "kg ready-to-cook weight",
|
@@ -64,15 +64,15 @@ def test_run_liveAnimal_chicken(mock_download_hestia, *args):
|
|
64
64
|
|
65
65
|
|
66
66
|
@patch(f"{class_path}._new_property", side_effect=fake_new_property)
|
67
|
-
@patch(f"{class_path}.
|
68
|
-
def test_run_liveAnimal_pig(
|
67
|
+
@patch(f"{class_path}.download_term")
|
68
|
+
def test_run_liveAnimal_pig(mock_download_term, *args):
|
69
69
|
with open(f"{fixtures_folder}/liveAnimal/pig/cycle.jsonld", encoding='utf-8') as f:
|
70
70
|
cycle = json.load(f)
|
71
71
|
|
72
72
|
with open(f"{fixtures_folder}/liveAnimal/pig/result.jsonld", encoding='utf-8') as f:
|
73
73
|
expected = json.load(f)
|
74
74
|
|
75
|
-
|
75
|
+
mock_download_term.return_value = {
|
76
76
|
"@id": "meatPigColdDressedCarcassWeight",
|
77
77
|
"@type": "Term",
|
78
78
|
"units": "kg cold dressed carcass weight",
|
@@ -95,15 +95,15 @@ def test_run_liveAnimal_pig(mock_download_hestia, *args):
|
|
95
95
|
|
96
96
|
|
97
97
|
@patch(f"{class_path}._new_property", side_effect=fake_new_property)
|
98
|
-
@patch(f"{class_path}.
|
99
|
-
def test_run_liveAnimal_sheepLamb(
|
98
|
+
@patch(f"{class_path}.download_term")
|
99
|
+
def test_run_liveAnimal_sheepLamb(mock_download_term, *args):
|
100
100
|
with open(f"{fixtures_folder}/liveAnimal/sheepLamb/cycle.jsonld", encoding='utf-8') as f:
|
101
101
|
cycle = json.load(f)
|
102
102
|
|
103
103
|
with open(f"{fixtures_folder}/liveAnimal/sheepLamb/result.jsonld", encoding='utf-8') as f:
|
104
104
|
expected = json.load(f)
|
105
105
|
|
106
|
-
|
106
|
+
mock_download_term.return_value = {
|
107
107
|
"@id": "meatSheepColdDressedCarcassWeight",
|
108
108
|
"@type": "Term",
|
109
109
|
"units": "kg cold dressed carcass weight",
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from unittest.mock import patch
|
2
2
|
import json
|
3
3
|
from hestia_earth.schema import CycleFunctionalUnit
|
4
|
-
from tests.utils import fixtures_path, fake_new_property
|
4
|
+
from tests.utils import fixtures_path, fake_new_property
|
5
5
|
|
6
6
|
from hestia_earth.models.globalCropWaterModel2008.rootingDepth import (
|
7
7
|
MODEL, TERM_ID, run, _should_run, _should_run_product
|
@@ -16,6 +16,10 @@ TERMS = [
|
|
16
16
|
]
|
17
17
|
|
18
18
|
|
19
|
+
def fake_download_term(node_id, *args):
|
20
|
+
return {"@type": "Term", "@id": node_id}
|
21
|
+
|
22
|
+
|
19
23
|
@patch(f"{class_path}.get_irrigation_terms", return_value=TERMS)
|
20
24
|
def test_should_run(*args):
|
21
25
|
cycle = {'products': []}
|
@@ -53,7 +57,7 @@ def test_should_run_product(mock_get_value, *args):
|
|
53
57
|
|
54
58
|
|
55
59
|
@patch(f"{class_path}.get_irrigation_terms", return_value=TERMS)
|
56
|
-
@patch(f"{class_path}.
|
60
|
+
@patch(f"{class_path}.download_term", side_effect=fake_download_term)
|
57
61
|
@patch(f"{class_path}._new_property", side_effect=fake_new_property)
|
58
62
|
def test_run(*args):
|
59
63
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
@@ -67,7 +71,7 @@ def test_run(*args):
|
|
67
71
|
|
68
72
|
|
69
73
|
@patch(f"{class_path}.get_irrigation_terms", return_value=TERMS)
|
70
|
-
@patch(f"{class_path}.
|
74
|
+
@patch(f"{class_path}.download_term", side_effect=fake_download_term)
|
71
75
|
@patch(f"{class_path}._new_property", side_effect=fake_new_property)
|
72
76
|
def test_gap_fill_with_irrigation(*args):
|
73
77
|
with open(f"{fixtures_folder}/with-irrigation/cycle.jsonld", encoding='utf-8') as f:
|
@@ -16,7 +16,7 @@ def fake_download_hestia(id: str, *args):
|
|
16
16
|
|
17
17
|
|
18
18
|
@patch(f"{class_path}.download_hestia", side_effect=fake_download_hestia)
|
19
|
-
@patch(f"{class_path}.
|
19
|
+
@patch(f"{class_path}.include_methodModel", side_effect=_set_methodModel)
|
20
20
|
def test_run(*args):
|
21
21
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
22
22
|
cycle = json.load(f)
|
@@ -8,7 +8,7 @@ from tests.utils import fixtures_path, fake_new_management
|
|
8
8
|
from hestia_earth.models.faostat2018.utils import MODEL as FAOSTAT_MODEL
|
9
9
|
from hestia_earth.models.hestia.landCover import (
|
10
10
|
MODEL, MODEL_KEY, get_changes, _estimate_maximum_forest_change,
|
11
|
-
run, site_area_sum_to_100, _get_sums_of_crop_expansion
|
11
|
+
run, site_area_sum_to_100, _get_sums_of_crop_expansion, _get_sum_for_land_category, scale_values_to_one
|
12
12
|
)
|
13
13
|
|
14
14
|
CLASS_PATH = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
|
@@ -55,9 +55,7 @@ def _download_fixture(filepath: str):
|
|
55
55
|
return recfromcsv_mod(filename=filepath)
|
56
56
|
|
57
57
|
|
58
|
-
|
59
|
-
def test_get_changes(mock_lookup):
|
60
|
-
mock_lookup.return_value = _download_fixture(f"{faostat_fixtures_folder}/gadm-afg.csv")
|
58
|
+
def test_get_changes():
|
61
59
|
result, missing_values = get_changes(
|
62
60
|
country_id="GADM-AFG",
|
63
61
|
end_year=2010
|
@@ -185,6 +183,55 @@ def test_get_sums_of_crop_expansion():
|
|
185
183
|
assert result == (940270.0, 28139.0)
|
186
184
|
|
187
185
|
|
186
|
+
def test_get_sum_for_land_category():
|
187
|
+
values = {
|
188
|
+
"mangoes_guavas_and_mangosteens": "2022:5",
|
189
|
+
"kiwi_fruit": "2020:4",
|
190
|
+
"maize_corn": "2020:3",
|
191
|
+
"other_beans_green": "2021:2",
|
192
|
+
"olives": "2020:-1"
|
193
|
+
}
|
194
|
+
fao_stat_to_ipcc_type = {
|
195
|
+
"mangoes_guavas_and_mangosteens": "Perennial crops",
|
196
|
+
'kiwi_fruit': "Perennial crops",
|
197
|
+
'maize_corn': "Annual crops",
|
198
|
+
'other_beans_green': "Annual crops",
|
199
|
+
'olives': "Perennial crops"
|
200
|
+
}
|
201
|
+
result = _get_sum_for_land_category(
|
202
|
+
values=values,
|
203
|
+
year=2020,
|
204
|
+
ipcc_land_use_category="Perennial crops",
|
205
|
+
fao_stat_to_ipcc_type=fao_stat_to_ipcc_type,
|
206
|
+
include_negatives=True
|
207
|
+
)
|
208
|
+
assert result == 3.0
|
209
|
+
|
210
|
+
|
211
|
+
@pytest.mark.parametrize(
|
212
|
+
"dictionary,expected_result",
|
213
|
+
[
|
214
|
+
(
|
215
|
+
{"a": 0, "b": 0, "c": 0},
|
216
|
+
{"a": 0, "b": 0, "c": 0}
|
217
|
+
),
|
218
|
+
(
|
219
|
+
{"a": 1000},
|
220
|
+
{"a": 1}
|
221
|
+
),
|
222
|
+
(
|
223
|
+
{"a": 10, "b": 5, "c": 3},
|
224
|
+
{"a": 0.5556, "b": 0.2778, "c": 0.1667}
|
225
|
+
)
|
226
|
+
]
|
227
|
+
)
|
228
|
+
def test_scale_values_to_one(dictionary, expected_result):
|
229
|
+
result = scale_values_to_one(dictionary)
|
230
|
+
for k, v in result.items():
|
231
|
+
assert k in expected_result
|
232
|
+
assert round(v, 3) == round(expected_result[k], 3)
|
233
|
+
|
234
|
+
|
188
235
|
@pytest.mark.parametrize(
|
189
236
|
"subfolder",
|
190
237
|
[
|
@@ -199,7 +246,8 @@ def test_get_sums_of_crop_expansion():
|
|
199
246
|
"prior_landCover",
|
200
247
|
"nigeria_cassava",
|
201
248
|
"cover_crops",
|
202
|
-
"missing_fao_date"
|
249
|
+
"missing_fao_date",
|
250
|
+
"iran_sistan"
|
203
251
|
]
|
204
252
|
)
|
205
253
|
@patch(f"{CLASS_PATH}._new_management", side_effect=fake_new_management)
|
@@ -10,11 +10,13 @@ class_path_utils = f"hestia_earth.models.{MODEL}.pastureGrass_utils"
|
|
10
10
|
fixtures_folder = f"{fixtures_path}/{MODEL}/animal/{MODEL_KEY}"
|
11
11
|
|
12
12
|
|
13
|
-
def fake_download_hestia(
|
13
|
+
def fake_download_hestia(term, *args):
|
14
|
+
term_id = term.get('@id') if isinstance(term, dict) else term
|
15
|
+
return TERMS_BY_ID.get(term_id, {})
|
14
16
|
|
15
17
|
|
16
18
|
@patch(f"{class_path_utils}.download_hestia", side_effect=fake_download_hestia)
|
17
|
-
@patch("hestia_earth.models.utils.property.
|
19
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_hestia)
|
18
20
|
@patch(f"{class_path}.get_wool_terms", return_value=WOOL_TERMS)
|
19
21
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=MILK_YIELD_TERMS)
|
20
22
|
@patch(f"{class_path}._new_input", side_effect=fake_new_input)
|
@@ -30,7 +32,7 @@ def test_run_with_feed(*args):
|
|
30
32
|
|
31
33
|
|
32
34
|
@patch(f"{class_path_utils}.download_hestia", side_effect=fake_download_hestia)
|
33
|
-
@patch("hestia_earth.models.utils.property.
|
35
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_hestia)
|
34
36
|
@patch(f"{class_path}.get_wool_terms", return_value=WOOL_TERMS)
|
35
37
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=MILK_YIELD_TERMS)
|
36
38
|
@patch(f"{class_path}._new_input", side_effect=fake_new_input)
|
@@ -16,7 +16,7 @@ CROP_RESIDUE_TERM = {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
|
19
|
-
@patch('hestia_earth.models.utils.completeness.
|
19
|
+
@patch('hestia_earth.models.utils.completeness.download_term', return_value=CROP_RESIDUE_TERM)
|
20
20
|
@patch(f"{class_path}._should_run_product", return_value=True)
|
21
21
|
def test_should_run(*args):
|
22
22
|
crop_product = {'term': {'termType': TermTermType.CROP.value}}
|
@@ -33,7 +33,7 @@ def test_should_run(*args):
|
|
33
33
|
assert should_run is True
|
34
34
|
|
35
35
|
|
36
|
-
@patch('hestia_earth.models.utils.completeness.
|
36
|
+
@patch('hestia_earth.models.utils.completeness.download_term', return_value=CROP_RESIDUE_TERM)
|
37
37
|
@patch(f"{class_path}.get_yield_dm", return_value=None)
|
38
38
|
def test_should_run_product(mock_get_yield_dm, *args):
|
39
39
|
product = {'term': {'@id': 'maizeGrain'}}
|
@@ -51,7 +51,7 @@ def test_should_run_product(mock_get_yield_dm, *args):
|
|
51
51
|
assert _should_run_product(product) is True
|
52
52
|
|
53
53
|
|
54
|
-
@patch('hestia_earth.models.utils.completeness.
|
54
|
+
@patch('hestia_earth.models.utils.completeness.download_term', return_value=CROP_RESIDUE_TERM)
|
55
55
|
@patch(f"{class_path}._new_product", side_effect=fake_new_product)
|
56
56
|
def test_run_crop(*args):
|
57
57
|
with open(f"{fixtures_folder}/crop/cycle.jsonld", encoding='utf-8') as f:
|
@@ -64,7 +64,7 @@ def test_run_crop(*args):
|
|
64
64
|
assert value == expected
|
65
65
|
|
66
66
|
|
67
|
-
@patch('hestia_earth.models.utils.completeness.
|
67
|
+
@patch('hestia_earth.models.utils.completeness.download_term', return_value=CROP_RESIDUE_TERM)
|
68
68
|
@patch(f"{class_path}._new_product", side_effect=fake_new_product)
|
69
69
|
def test_run_forage(*args):
|
70
70
|
with open(f"{fixtures_folder}/forage/cycle.jsonld", encoding='utf-8') as f:
|
@@ -16,7 +16,7 @@ CROP_RESIDUE_TERM = {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
|
19
|
-
@patch('hestia_earth.models.utils.completeness.
|
19
|
+
@patch('hestia_earth.models.utils.completeness.download_term', return_value=CROP_RESIDUE_TERM)
|
20
20
|
@patch(f"{class_path}._should_run_product", return_value=True)
|
21
21
|
def test_should_run(*args):
|
22
22
|
crop_product = {'term': {'termType': TermTermType.CROP.value}}
|
@@ -33,7 +33,7 @@ def test_should_run(*args):
|
|
33
33
|
assert should_run is True
|
34
34
|
|
35
35
|
|
36
|
-
@patch('hestia_earth.models.utils.completeness.
|
36
|
+
@patch('hestia_earth.models.utils.completeness.download_term', return_value=CROP_RESIDUE_TERM)
|
37
37
|
@patch(f"{class_path}.get_yield_dm", return_value=None)
|
38
38
|
def test_should_run_product(mock_get_yield_dm, *args):
|
39
39
|
product = {'term': {'@id': 'maizeGrain'}}
|
@@ -51,7 +51,7 @@ def test_should_run_product(mock_get_yield_dm, *args):
|
|
51
51
|
assert _should_run_product(product) is True
|
52
52
|
|
53
53
|
|
54
|
-
@patch('hestia_earth.models.utils.completeness.
|
54
|
+
@patch('hestia_earth.models.utils.completeness.download_term', return_value=CROP_RESIDUE_TERM)
|
55
55
|
@patch(f"{class_path}._new_product", side_effect=fake_new_product)
|
56
56
|
def test_run_crop(*args):
|
57
57
|
with open(f"{fixtures_folder}/crop/cycle.jsonld", encoding='utf-8') as f:
|
@@ -64,7 +64,7 @@ def test_run_crop(*args):
|
|
64
64
|
assert value == expected
|
65
65
|
|
66
66
|
|
67
|
-
@patch('hestia_earth.models.utils.completeness.
|
67
|
+
@patch('hestia_earth.models.utils.completeness.download_term', return_value=CROP_RESIDUE_TERM)
|
68
68
|
@patch(f"{class_path}._new_product", side_effect=fake_new_product)
|
69
69
|
def test_run_forage(*args):
|
70
70
|
with open(f"{fixtures_folder}/forage/cycle.jsonld", encoding='utf-8') as f:
|
@@ -15,7 +15,7 @@ TERMS_BY_ID = {
|
|
15
15
|
}
|
16
16
|
|
17
17
|
|
18
|
-
def
|
18
|
+
def fake_download_term(term_id: str, *args): return TERMS_BY_ID[term_id]
|
19
19
|
|
20
20
|
|
21
21
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=[])
|
@@ -53,7 +53,7 @@ def test_should_run(mock_feed, mock_lookup_value, *args):
|
|
53
53
|
|
54
54
|
|
55
55
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=[])
|
56
|
-
@patch("hestia_earth.models.utils.property.
|
56
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
|
57
57
|
# patch get_node_property to read value from lookups only
|
58
58
|
@patch('hestia_earth.models.utils.property.get_node_property', return_value=None)
|
59
59
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
@@ -69,7 +69,7 @@ def test_run(*args):
|
|
69
69
|
|
70
70
|
|
71
71
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=[])
|
72
|
-
@patch("hestia_earth.models.utils.property.
|
72
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
|
73
73
|
# patch get_node_property to read value from lookups only
|
74
74
|
@patch('hestia_earth.models.utils.property.get_node_property', return_value=None)
|
75
75
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
@@ -85,7 +85,7 @@ def test_run_dairy(*args):
|
|
85
85
|
|
86
86
|
|
87
87
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=['milkYieldPerBuffaloRaw'])
|
88
|
-
@patch("hestia_earth.models.utils.property.
|
88
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
|
89
89
|
# patch get_node_property to read value from lookups only
|
90
90
|
@patch('hestia_earth.models.utils.property.get_node_property', return_value={})
|
91
91
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
@@ -101,7 +101,7 @@ def test_run_with_milkYield(*args):
|
|
101
101
|
|
102
102
|
|
103
103
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=[])
|
104
|
-
@patch("hestia_earth.models.utils.property.
|
104
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
|
105
105
|
# patch get_node_property to read value from lookups only
|
106
106
|
@patch('hestia_earth.models.utils.property.get_node_property', return_value={})
|
107
107
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
@@ -117,7 +117,7 @@ def test_run_non_dairy(*args):
|
|
117
117
|
|
118
118
|
|
119
119
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=[])
|
120
|
-
@patch("hestia_earth.models.utils.property.
|
120
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
|
121
121
|
# patch get_node_property to read value from lookups only
|
122
122
|
@patch('hestia_earth.models.utils.property.get_node_property', return_value={})
|
123
123
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
@@ -133,7 +133,7 @@ def test_run_with_ionophores(*args):
|
|
133
133
|
|
134
134
|
|
135
135
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=[])
|
136
|
-
@patch("hestia_earth.models.utils.property.
|
136
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
|
137
137
|
# patch get_node_property to read value from lookups only
|
138
138
|
@patch('hestia_earth.models.utils.property.get_node_property', return_value={})
|
139
139
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
@@ -149,7 +149,7 @@ def test_run_without_ionophores(*args):
|
|
149
149
|
|
150
150
|
|
151
151
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=[])
|
152
|
-
@patch("hestia_earth.models.utils.property.
|
152
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
|
153
153
|
# patch get_node_property to read value from lookups only
|
154
154
|
@patch('hestia_earth.models.utils.property.get_node_property', return_value={})
|
155
155
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
@@ -162,7 +162,7 @@ def test_run_no_feed(*args):
|
|
162
162
|
|
163
163
|
|
164
164
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=[])
|
165
|
-
@patch("hestia_earth.models.utils.property.
|
165
|
+
@patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
|
166
166
|
# patch get_node_property to read value from lookups only
|
167
167
|
@patch('hestia_earth.models.utils.property.get_node_property', return_value={})
|
168
168
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
@@ -178,7 +178,7 @@ def test_run_with_system(*args):
|
|
178
178
|
|
179
179
|
|
180
180
|
@patch(f"hestia_earth.models.{MODEL}.utils.get_milkYield_terms", return_value=[])
|
181
|
-
@patch("hestia_earth.models.utils.property.
|
181
|
+
@patch("hestia_earth.models.utils.property.download_term", return_value={})
|
182
182
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
183
183
|
def test_run_default(*args):
|
184
184
|
with open(f"{fixtures_folder}/default-value/cycle.jsonld", encoding="utf-8") as f:
|
@@ -8,7 +8,7 @@ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
9
9
|
|
10
10
|
|
11
|
-
@patch(f"{class_path}.
|
11
|
+
@patch(f"{class_path}.get_region_lookup_value", return_value='0')
|
12
12
|
@patch(f"{class_path}.has_flooded_rice", return_value=False)
|
13
13
|
def test_should_run(mock_flooded_rice, *args):
|
14
14
|
# no cycleDuration => no run
|
@@ -0,0 +1,83 @@
|
|
1
|
+
from functools import reduce
|
2
|
+
import json
|
3
|
+
from pytest import mark
|
4
|
+
from os.path import isfile
|
5
|
+
from unittest.mock import MagicMock, patch
|
6
|
+
|
7
|
+
from tests.utils import fake_new_emission, fixtures_path, order_list
|
8
|
+
|
9
|
+
from hestia_earth.models.ipcc2019.nonCo2EmissionsToAirNaturalVegetationBurning import run, _should_run
|
10
|
+
|
11
|
+
class_path = 'hestia_earth.models.ipcc2019.nonCo2EmissionsToAirNaturalVegetationBurning'
|
12
|
+
fixtures_folder = f"{fixtures_path}/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning"
|
13
|
+
|
14
|
+
|
15
|
+
def _load_fixture(path: str, default=None):
|
16
|
+
if isfile(path):
|
17
|
+
with open(path, encoding="utf-8") as f:
|
18
|
+
return json.load(f)
|
19
|
+
return default
|
20
|
+
|
21
|
+
|
22
|
+
RUN_SCENARIOS = [
|
23
|
+
("forest-to-cropland", 4),
|
24
|
+
("historical-land-cover-mix", 3),
|
25
|
+
("deforestation-reforestation", 1), # gains should not offset losses
|
26
|
+
("no-clearance-via-fire", 1), # LUC in the UK, which has a percentage burned factor of 0
|
27
|
+
("forest-to-cropland-with-ground-cover", 4) # Cover crops/ground covers should be ignored
|
28
|
+
]
|
29
|
+
|
30
|
+
|
31
|
+
RUN_PARAMS = reduce(
|
32
|
+
lambda params, scenario: params + [(scenario[0], scenario[1], i) for i in range(scenario[1])],
|
33
|
+
RUN_SCENARIOS,
|
34
|
+
list()
|
35
|
+
)
|
36
|
+
"""List of (subfolder: str, num_cycles: int, cycle_index: int)."""
|
37
|
+
|
38
|
+
RUN_IDS = [f"{param[0]}, cycle{param[2]}" for param in RUN_PARAMS]
|
39
|
+
|
40
|
+
|
41
|
+
@mark.parametrize("subfolder, num_cycles, cycle_index", RUN_PARAMS, ids=RUN_IDS)
|
42
|
+
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
43
|
+
@patch(f"{class_path}.related_cycles")
|
44
|
+
@patch(f"{class_path}._get_site")
|
45
|
+
def test_run(
|
46
|
+
get_site_mock: MagicMock,
|
47
|
+
related_cycles_mock: MagicMock,
|
48
|
+
_new_emission_mock: MagicMock,
|
49
|
+
subfolder: str,
|
50
|
+
num_cycles: int,
|
51
|
+
cycle_index: int
|
52
|
+
):
|
53
|
+
"""
|
54
|
+
Test `run` function for each cycle in each scenario.
|
55
|
+
"""
|
56
|
+
site = _load_fixture(f"{fixtures_folder}/{subfolder}/site.jsonld")
|
57
|
+
cycle = _load_fixture(f"{fixtures_folder}/{subfolder}/cycle{cycle_index}.jsonld")
|
58
|
+
expected = _load_fixture(f"{fixtures_folder}/{subfolder}/result{cycle_index}.jsonld", default=[])
|
59
|
+
|
60
|
+
cycles = [_load_fixture(f"{fixtures_folder}/{subfolder}/cycle{i}.jsonld") for i in range(num_cycles)]
|
61
|
+
|
62
|
+
get_site_mock.return_value = site
|
63
|
+
related_cycles_mock.return_value = cycles
|
64
|
+
|
65
|
+
result = run(cycle)
|
66
|
+
assert order_list(result) == order_list(expected)
|
67
|
+
|
68
|
+
|
69
|
+
def test_should_run_no_data():
|
70
|
+
CYCLE = {}
|
71
|
+
EXPECTED = False
|
72
|
+
|
73
|
+
result, *_ = _should_run(CYCLE)
|
74
|
+
assert result == EXPECTED
|
75
|
+
|
76
|
+
|
77
|
+
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
78
|
+
def test_run_no_data(*_):
|
79
|
+
CYCLE = {}
|
80
|
+
EXPECTED = []
|
81
|
+
|
82
|
+
result = run(CYCLE)
|
83
|
+
assert result == EXPECTED
|