mirror of https://gitlab.com/pamhyr/pamhyr2
tests: Add AddFiles scenario tests.
parent
1cfc7e6638
commit
d50f617a85
|
|
@ -107,6 +107,55 @@ class StudyScenarioTestCase(unittest.TestCase):
|
|||
self.assertEqual(study.description, "bar")
|
||||
self.assertEqual(study.status.scenario_id, nid)
|
||||
|
||||
def test_save_study_add_files(self):
|
||||
study = Study.new("foo", "bar")
|
||||
study.river.additional_files.new(0)
|
||||
|
||||
dir = tempfile.mkdtemp()
|
||||
f = os.path.join(dir, "foo.pamhyr")
|
||||
study.filename = f
|
||||
study.save()
|
||||
study.close()
|
||||
|
||||
study = Study.open(f)
|
||||
self.assertNotEqual(study, None)
|
||||
self.assertEqual(study.name, "foo")
|
||||
self.assertEqual(study.description, "bar")
|
||||
self.assertEqual(len(study.river.additional_files), 1)
|
||||
|
||||
new = study.new_scenario_from_current()
|
||||
nid = new.id
|
||||
|
||||
study.river.additional_files.new(1)
|
||||
|
||||
study.save()
|
||||
study.close()
|
||||
|
||||
study = Study.open(f)
|
||||
self.assertEqual(len(study.river.additional_files), 2)
|
||||
|
||||
def test_save_study_add_files_reload(self):
|
||||
study = Study.new("foo", "bar")
|
||||
study.river.additional_files.new(0)
|
||||
|
||||
dir = tempfile.mkdtemp()
|
||||
f = os.path.join(dir, "foo.pamhyr")
|
||||
study.filename = f
|
||||
study.save()
|
||||
|
||||
new = study.new_scenario_from_current()
|
||||
nid = new.id
|
||||
|
||||
study.river.additional_files.new(1)
|
||||
self.assertEqual(len(study.river.additional_files), 2)
|
||||
|
||||
study.save()
|
||||
study.reload_from_scenario(study.scenarios[0])
|
||||
self.assertEqual(len(study.river.additional_files), 1)
|
||||
|
||||
study.reload_from_scenario(study.scenarios[nid])
|
||||
self.assertEqual(len(study.river.additional_files), 2)
|
||||
|
||||
|
||||
class RiverTestCase(unittest.TestCase):
|
||||
def test_create_river(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue