mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
tests: Add AddFiles scenario tests.
This commit is contained in:
1 parent
1cfc7e6638
commit
d50f617a85
1 file changed
+49
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user