Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    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")
Exemplo n.º 4
0
    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")
Exemplo n.º 5
0
 def test_execute_no_step(self):
     with self.assertRaises(TypeError):
         run.execute_step("foo", sync=True)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 def test_execute_no_step(self):
     with self.assertRaises(TypeError):
         run.execute_step("foo", sync=True)
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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)