mirror of https://gitlab.com/pamhyr/pamhyr2
tests: Add nodes scenario tests.
parent
04ce79462c
commit
76559f6af8
|
|
@ -166,6 +166,44 @@ class StudyScenarioTestCase(unittest.TestCase):
|
|||
study.reload_from_scenario(study.scenarios[nid])
|
||||
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):
|
||||
def test_create_river(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue