tests: Add nodes scenario tests.

scenarios
Pierre-Antoine 2025-08-22 11:07:50 +02:00
parent 04ce79462c
commit 76559f6af8
1 changed files with 38 additions and 0 deletions

View File

@ -166,6 +166,44 @@ class StudyScenarioTestCase(unittest.TestCase):
study.reload_from_scenario(study.scenarios[nid]) study.reload_from_scenario(study.scenarios[nid])
self.assertEqual(len(study.river.additional_files), 2) self.assertEqual(len(study.river.additional_files), 2)
def test_scenario_river_nodes(self):
study = Study.new("foo", "bar")
study.river.additional_files.new(0)
self.assertNotEqual(study.river, None)
dir = tempfile.mkdtemp()
f = os.path.join(dir, "foo.pamhyr")
study.filename = f
study.save()
# Add nodes
n0 = study.river.add_node()
n1 = study.river.add_node(x=1.0, y=0.0)
n2 = study.river.add_node(x=0.0, y=1.0)
self.assertEqual(study.river.nodes_counts(), 3)
study.save()
# New scenario
new = study.new_scenario_from_current()
nid = new.id
n3 = study.river.add_node(x=0.0, y=1.0)
study.save()
self.assertEqual(study.river.nodes_counts(), 4)
study.reload_from_scenario(study.scenarios[0])
self.assertEqual(study.river.nodes_counts(), 3)
study.reload_from_scenario(study.scenarios[nid])
self.assertEqual(study.river.nodes_counts(), 4)
study.save()
class RiverTestCase(unittest.TestCase): class RiverTestCase(unittest.TestCase):
def test_create_river(self): def test_create_river(self):