Skip to content

Commit c061cc5

Browse files
committed
Add integration test
1 parent b88df0d commit c061cc5

3 files changed

Lines changed: 98 additions & 20 deletions

File tree

tests/integration/Snakefile

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
# Emulate a user configuring the module.
22
configfile: workflow.source_path("./test_config.yaml")
33

4-
# Emulate how another workflow might create inputs for this module.
5-
rule create_external_input:
6-
message: "Example of a rule external to your module."
4+
rule download_netherlands_shapes:
5+
message: "Download and unzip the Netherlands shapes."
76
output:
8-
text_file = "results/module_area_potentials/resources/user/user_message.md"
9-
run:
10-
from pathlib import Path
11-
from textwrap import dedent
12-
text = dedent("""Modular workflows can be used by more than one project!
13-
For example, this text comes from a file external to the module.
14-
Try your best to make this workflow reusable so that others may benefit from your methods."""
15-
)
16-
file_path = Path(output.text_file)
17-
with file_path.open("w") as f:
18-
f.write(text)
7+
"results/module_area_potentials/resources/user/shapes/NLD.parquet",
8+
shell:
9+
"""
10+
curl -sSLo {output} https://surfdrive.surf.nl/files/index.php/s/ey3RmiCbajp69oQ/download
11+
"""
12+
13+
rule download_netherlands_protected_areas:
14+
message: "Download and unzip a dummy drop-in dataset for Netherlands protected areas (not based on WDPA)."
15+
output:
16+
zipfile="results/module_area_potentials/resources/user/wdpa.gdb.zip",
17+
wdpa=directory("results/module_area_potentials/resources/user/wdpa.gdb"),
18+
shell:
19+
"""
20+
curl -sSLo {output.zipfile} https://surfdrive.surf.nl/files/index.php/s/msuXQETNbCWawDh/download
21+
unzip {output.zipfile} -d results/module_area_potentials/resources/user/
22+
"""
1923

2024
# Import the module and configure it.
2125
# `snakefile:` specifies the module. It can use file paths and special github(...) / gitlab(...) markers
@@ -30,7 +34,9 @@ use rule * from module_area_potentials as module_area_potentials_*
3034

3135
# Request something from the module
3236
rule all:
33-
message: "A generic test case for your module."
37+
message: "Run the module for the Netherlands shapes."
3438
default_target: True
3539
input:
36-
"results/module_area_potentials/results/combined_text.md"
40+
"results/module_area_potentials/resources/user/shapes/NLD.parquet",
41+
"results/module_area_potentials/resources/user/wdpa.gdb",
42+
"results/module_area_potentials/results/NLD/area_potential_report.html",

tests/integration/test_config.yaml

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,77 @@
11
module_area_potentials:
2-
dummy_text: >-
3-
Configuration values (like this one) are also external to the module!
4-
This gives users a lot of flexibility in how they apply your methodology to solve their particular needs.
2+
# Options for buffering: either a string of the form "epsg:xxxx" or "UTM"/"utm"
3+
# - "UTM": project each shape to the UTM zone of its centroid for buffering
4+
# - "epsg:xxxx": use the specified CRS for all buffering
5+
# A good option is "epsg:8857" (WGS 84 / Equal Earth Greenwich) for global coverage
6+
buffer_crs: "epsg:8857"
7+
8+
techs:
9+
pv_rooftop:
10+
initial_area: settlement_area
11+
continuous_layers:
12+
settlement_share:
13+
min: 0.01
14+
max: 1
15+
share: 0.8
16+
binary_layers:
17+
regions_maritime: 0
18+
regions_land: 1
19+
protected: 0
20+
# Include all land cover types; selection is done by settlement_share
21+
landcover_FARM: 1
22+
landcover_FOREST: 1
23+
landcover_URBAN: 1
24+
landcover_OTHER: 1
25+
landcover_NOT_SUITABLE: 0
26+
landcover_WATER: 0
27+
pv_open_field:
28+
initial_area: pixel_area
29+
continuous_layers:
30+
slope:
31+
min: 0
32+
max: 3
33+
settlement_share:
34+
min: 0
35+
max: 0.01
36+
binary_layers:
37+
regions_maritime: 0
38+
regions_land: 1
39+
protected: 0
40+
landcover_FARM: 0.1
41+
landcover_FOREST: 0
42+
landcover_URBAN: 0
43+
landcover_OTHER: 0.2
44+
landcover_NOT_SUITABLE: 0
45+
landcover_WATER: 0
46+
wind_onshore:
47+
initial_area: pixel_area
48+
continuous_layers:
49+
slope:
50+
min: 0
51+
max: 20
52+
settlement_share:
53+
min: 0
54+
max: 0.01
55+
binary_layers:
56+
regions_maritime: 0
57+
regions_land: 1
58+
protected: 0
59+
landcover_FARM: 0.2
60+
landcover_FOREST: 0.05
61+
landcover_URBAN: 0
62+
landcover_OTHER: 0.3
63+
landcover_NOT_SUITABLE: 0
64+
landcover_WATER: 0
65+
wind_offshore:
66+
initial_area: pixel_area
67+
continuous_layers:
68+
bathymetry:
69+
min: -50
70+
max: 0
71+
share: 0.8
72+
binary_layers:
73+
regions_land: 0
74+
regions_maritime: 1
75+
protected: 0
76+
shapes_buffer:
77+
land: 10000 # meters

workflow/rules/prepare.smk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ rule cutout_landcover:
1515
rio clip --overwrite "{input.landcover}" "{output}" --bounds "$(fio info '{input.shapes}' --bounds)"
1616
"""
1717

18-
1918
rule cutout_settlement:
2019
message:
2120
"Cut settlement data to the bounds of the input shapefile."

0 commit comments

Comments
 (0)