コード例 #1
0
ファイル: tests.py プロジェクト: ad3002/PyExp
 def test_get_project(self):
     pid = "test_project"
     data = {"data": "data", "foo": "bar", "path_to": "data/test_data", "pid": "test_project"}
     experiment_settings = TestExperimentSettings()
     manager = ProjectManager(experiment_settings)
     project, settings = manager.get_project(pid)
     self.assertEqual(settings["full_path_to"].count("data"), 3)
     self.assertEqual(settings["files"]["test_file"].count("data"), 3)
     self.assertEqual(settings["files"]["test_file"].count("test.txt"), 1)
コード例 #2
0
ファイル: tests.py プロジェクト: ad3002/PyExp
 def test_avalibale_steps(self):
     project = {"pid": "test_project"}
     pid = "test_project"
     manager = ProjectManager(TestExperimentSettings())
     project, settings = manager.get_project(pid)
     exp = TestExperiment(settings, project, name="name")
     step = exp.find_step("step_a")
     self.assertEqual(
         step, {"stage": "Test Stage A", "name": "step_a", "cf": sum, "data": None, "check": sum, "pre": None}
     )
     stage = exp.find_steps_by_stage("Test Stage A")
     self.assertEqual(len(stage), 2)
     all_steps = exp.get_avaliable_steps()
     self.assertEqual(len(all_steps), 4)
コード例 #3
0
ファイル: tests.py プロジェクト: ad3002/PyExp
 def test_initiation(self):
     project = {"pid": "test_project"}
     pid = "test_project"
     manager = ProjectManager(TestExperimentSettings())
     project, settings = manager.get_project(pid)
     exp = TestExperiment(settings, project)
     self.assertEqual(exp.name, "default")
     exp = TestExperiment(settings, project, name="name")
     self.assertEqual(exp.name, "name")
     self.assertEqual(exp.logger, None)
     self.assertEqual(exp.force, False)
     self.assertEqual(exp.settings, settings)
     self.assertEqual(exp.project, project)
     self.assertEqual(exp.sp, 0)
     self.assertEqual(exp.pid, "test_project")
     self.assertEqual(exp.sid2step, {})
     self.assertEqual(exp.manager, None)
     self.assertEqual(exp.all_steps, STEPS)
     self.assertEqual(exp.get_settings(), settings)
     exp.clear_settings()
     self.assertEqual(exp.settings, None)
コード例 #4
0
ファイル: tests.py プロジェクト: ad3002/PyExp
 def test_step_adding(self):
     project = {"pid": "test_project"}
     pid = "test_project"
     manager = ProjectManager(TestExperimentSettings())
     project, settings = manager.get_project(pid)
     exp = TestExperiment(settings, project, name="name")
     for i, step in enumerate(exp.get_avaliable_steps()):
         s = AbstractStep(step["name"], step["data"], step["cf"])
         if i == 0:
             s0 = s
         if i == 1:
             s1 = s
         exp.add_step(s)
         self.assertEqual(exp.sp, i + 1)
         self.assertEqual(exp.sid2step[i], s)
         self.assertEqual(exp.sid2step[i].sid, i)
     self.assertEqual(exp.get_step(0), s0)
     exp.remove_step(0)
     self.assertEqual(exp.get_step(0), None)
     exp.change_step(0, s1)
     self.assertEqual(exp.get_step(0), s1)
     self.assertEqual(exp.get_as_dict()["name"], "name")
コード例 #5
0
ファイル: tests.py プロジェクト: ad3002/PyExp
 def test_project_adding(self):
     pid = "test_project"
     data = {"data": "data", "foo": "bar", "path_to": "data/test_data", "pid": "test_project"}
     experiment_settings = TestExperimentSettings()
     manager = ProjectManager(experiment_settings)
     manager.add_project(pid, data, init=True, force=True)
     self.assertTrue(os.path.isfile("projects/test_project.yaml"))
     self.assertTrue(os.path.isdir("data/data/test_data/test/folder"))
     self.assertRaises(ProjectManagerException, manager.add_project, pid, data, init=True)
     data = {"data": "data", "foo": "bar"}
     self.assertRaises(ProjectManagerException, manager.add_project, pid, data, init=True)
     data = {"data": "data", "foo": "bar", "path_to": "data/test_data", "pid": "test_project"}
     manager.add_project(pid, data, init=True, force=True)
     self.assertEqual(manager.get_all_projects(), ["test_project.yaml"])