def test_default_generate_without_model_or_conditions(self): with mock.patch("tests.steps.Step1.model", None): with self.assertRaises(NotImplementedError): run.execute_step(Step1, sync=True) with mock.patch("tests.steps.Step1.conditions", None): with self.assertRaises(NotImplementedError): run.execute_step(Step1, sync=True)
def test_execute_step(self): sample_id = None with db.session_scope() as session: sample = SampleModel(name=None) session.add(sample) session.commit() sample_id = sample.id run.execute_step(Step1, sync=True) with db.session_scope() as session: query = session.query(SampleModel) self.assertEqual(query.count(), 1) sample = session.query(SampleModel).get(sample_id) self.assertEqual(sample.name, "Step1") run.execute_step(Step2, sync=True) with db.session_scope() as session: query = session.query(SampleModel) self.assertEqual(query.count(), 2) sample = session.query(SampleModel).get(sample_id) self.assertEqual(sample.name, "Step2") run.execute_step(Step1, sync=True) with db.session_scope() as session: query = session.query(SampleModel) self.assertEqual(query.count(), 2) sample = session.query(SampleModel).get(sample_id) self.assertEqual(sample.name, "Step2")
def test_execute_no_step(self): with self.assertRaises(TypeError): run.execute_step("foo", sync=True)
def test_step_return_no_model(self): with mock.patch("tests.steps.Step1.generate", return_value=[None]): with self.assertRaises(TypeError): run.execute_step(Step1, sync=True)
def test_procces_corectly_created(self, *args): with mock.patch("tests.steps.Step1.procno", 20): procs = run.execute_step(Step1) self.assertEqual(len(procs), 20)