Skip to content

Commit

Permalink
revise for pass the test
Browse files Browse the repository at this point in the history
  • Loading branch information
liuly12 committed Sep 14, 2024
1 parent 1197e6f commit 7f0063d
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 144 deletions.
75 changes: 75 additions & 0 deletions docs/demo/examples/test_customise_orchestration_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
orchestration:
- Groundwater: infiltrate
- Sewer: make_discharge

nodes:
Sewer:
type_: Sewer
name: my_sewer
capacity: 0.04

Groundwater:
type_: Groundwater
name: my_groundwater
capacity: 100
area: 100

River:
type_: Node
name: my_river

Waste:
type_: Waste
name: my_outlet

arcs:
storm_outflow:
type_: Arc
name: storm_outflow
in_port: my_sewer
out_port: my_river

baseflow:
type_: Arc
name: baseflow
in_port: my_groundwater
out_port: my_river

catchment_outflow:
type_: Arc
name: catchment_outflow
in_port: my_river
out_port: my_outlet

pollutants:
- org-phosphorus
- phosphate
- ammonia
- solids
- temperature
- nitrate
- nitrite
- org-nitrogen
additive_pollutants:
- org-phosphorus
- phosphate
- ammonia
- solids
- nitrate
- nitrite
- org-nitrogen
non_additive_pollutants:
- temperature
float_accuracy: 1.0e-06

dates:
- '2000-01-01'
- '2000-01-02'
- '2000-01-03'
- '2000-01-04'
- '2000-01-05'
- '2000-01-06'
- '2000-01-07'
- '2000-01-08'
- '2000-01-09'
- '2000-01-10'

This file was deleted.

17 changes: 11 additions & 6 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from wsimod.orchestration.model import Model, to_datetime
import os


class MyTestClass(TestCase):
def assertDictAlmostEqual(self, d1, d2, accuracy=19):
"""
Expand Down Expand Up @@ -290,15 +291,19 @@ def test_run(self):
self.assertEqual(
0.03, my_model.nodes["my_land"].get_surface("urban").storage["volume"]
)

def test_customise_orchestration(self):
my_model = Model()
my_model.load(os.path.join(os.getcwd(), "docs", "demo", "examples", "test_examples"),
config_name='test_customise_orchestration_example.yaml')
revised_orchestration = [{'Land': 'run'},
{'Groundwater': 'infiltrate'},
{'Sewer': 'make_discharge'},
{'Land': 'apply_irrigation'}]
my_model.load(
os.path.join(os.getcwd(), "docs", "demo", "examples"),
config_name="test_customise_orchestration_example.yaml",
)
revised_orchestration = [
{"Groundwater": "infiltrate"},
{"Sewer": "make_discharge"},
]
self.assertListEqual(my_model.orchestration, revised_orchestration)


if __name__ == "__main__":
unittest.main()

0 comments on commit 7f0063d

Please sign in to comment.