Example #1
0
    def test_finish_nomoretasks(self):
        g = G(T(1, tasks.ConstTask(None)), C(1, "value", FINAL_TICK, "retval"))
        self.target.execute(g, {})

        self.next_ready()[-1].callback({"value": "Hello"})

        self.assertIsNone(self.next_ready())
Example #2
0
    def test_get_task_state_waiting_for_refiner(self):
        task = MockTask("in")
        g = G(T(1, tasks.ConstTask(None)), C(1, "value", 2, "in"), T(2, task),
              C(2, "out", FINAL_TICK, "retval"))
        self.target.execute(g, {"a": "refinedata"})

        self.assertEqual(traverser.TaskState.WAITING_FOR_REFINE_INPUTS,
                         self.target.get_task_state(TICK2))
Example #3
0
 def test_get_task_state_evaluated(self):
     g = G(T(1, tasks.ConstTask(None)), C(1, "value", 2, "in"),
           T(2, "task"), C(2, "out", FINAL_TICK, "retval"))
     self.target.execute(g, {})
     self.next_ready()[-1].callback(traverser.EvalResult({"value":
                                                          "Hello"}))
     self.assertEqual(traverser.TaskState.EVALUATED,
                      self.target.get_task_state(TICK1))
Example #4
0
    def test_finish(self):
        g = G(T(1, tasks.ConstTask(None)), C(1, "value", FINAL_TICK, "retval"))
        d = self.target.execute(g, {})
        self.next_ready()[-1].callback(traverser.EvalResult({"value":
                                                             "Hello"}))

        outputs = extract(d)
        self.assertEqual({"retval": "Hello"}, outputs)
Example #5
0
    def test_eval_fail(self):
        g = G(T(1, tasks.ConstTask(None)), C(1, "value", FINAL_TICK, "retval"))
        d = self.target.execute(g, {})
        self.next_ready()[-1].errback(failure.Failure(MockError()))

        f = twistit.extract_failure(d)
        self.assertTrue(f.check(traverser.EvaluationError))
        self.assertTrue(f.value.cause.check(MockError))
        self.assertEqual(Tick.parse_tick(1), f.value.tick)
Example #6
0
 def test_injest_result(self):
     g = G(T(1, tasks.ConstTask(None)), C(1, "value", 2, "in"),
           T(2, "task"), C(2, "out", FINAL_TICK, "retval"))
     self.target.execute(g, {})
     self.next_ready()[-1].callback(traverser.EvalResult({"value":
                                                          "Hello"}))
     self.assertEqual((TICK2, "task", {
         "in": "Hello"
     }),
                      self.next_ready()[1:-1])
Example #7
0
 def test_no_inputs_task_ready(self):
     g = G(T(1, tasks.ConstTask(None)), C(1, "value", FINAL_TICK, "retval"))
     self.target.execute(g, {})
     self.assertEqual((TICK1, tasks.ConstTask(None), {}),
                      self.next_ready()[1:-1])
     self.assertEqual(None, self.next_ready())
Example #8
0
 def test_get_task_state_waiting_for_inputs(self):
     g = G(T(1, tasks.ConstTask(None)), C(1, "value", 2, "in"),
           T(2, "task"), C(2, "out", FINAL_TICK, "retval"))
     self.target.execute(g, {})
     self.assertEqual(traverser.TaskState.WAITING_FOR_INPUTS,
                      self.target.get_task_state(TICK2))