Пример #1
0
    def test_requires_sequence(self):

        # we leave these untouched (no req. added)
        a1 = J(sl(0.1), label="a1")
        a2 = J(sl(0.1), label="a2")
        a3 = J(sl(0.1), label="a3")
        a4 = J(sl(0.1), label="a4")
        a5 = J(sl(0.1), label="a5")

        # re-create these each time to have fresh data
        def bs():
            b1 = J(sl(0.1), label="b1")
            b2 = J(sl(0.1), label="b2")
            b3 = J(sl(0.1), label="b3")
            return b1, b2, b3

        b1, b2, b3, *_ = bs()
        s1 = Seq(b1, b2, b3, required=[a1, a2])
        self.assertEqual(len(b1.required), 2)
        self.assertEqual(len(b2.required), 1)

        b1, b2, b3, *_ = bs()
        s1 = Seq(b1, b2, b3)
        s1.requires([a1, a2])
        self.assertEqual(len(b1.required), 2)
        self.assertEqual(len(b2.required), 1)
Пример #2
0
 def test_sequence4(self):
     "a sequence of 2 sequences"
     a1 = J(sl(0.1), label=1)
     a2 = J(sl(0.1), label=2)
     a3 = J(sl(0.1), label=3)
     a4 = J(sl(0.1), label=4)
     s1 = Seq(a1, a2)
     s2 = Seq(a3, a4)
     sched = Scheduler(Seq(s1, s2))
     list_sep(sched, sep + "sequence4")
     self.assertEqual(len(a1.required), 0)
     self.assertEqual(len(a2.required), 1)
     self.assertEqual(len(a3.required), 1)
     self.assertEqual(len(a4.required), 1)
     self.assertTrue(check_required_types(sched, "test_sequence4"))
     self.assertTrue(sched.orchestrate())
Пример #3
0
 def test_sequence6(self):
     "adding a sequence"
     sched = Scheduler()
     a1 = J(sl(0.1), label=1)
     a2 = J(sl(0.1), label=2)
     a3 = J(sl(0.1), label=3)
     sched.add(Seq(a1, a2, a3))
     self.assertTrue(sched.orchestrate())
Пример #4
0
 def test_creation_scheduler(self):
     sched = Scheduler()
     s = Seq(J(sl(1)), J(sl(2)), scheduler=sched)
     j = J(sl(3), required=s, scheduler=sched)
     # make sure that jobs appended in the sequence
     # even later on are also added to the scheduler
     s.append(J(sl(.5)))
     self.assertEqual(len(sched.jobs), 4)
     self.assertTrue(sched.rain_check())
     self.assertTrue(sched.orchestrate())
Пример #5
0
 def test_sequence5(self):
     "sequences with required"
     a1 = J(sl(0.1), label=1)
     a2 = J(sl(0.1), label=2)
     a3 = J(sl(0.1), label=3)
     a4 = J(sl(0.1), label=4)
     a5 = J(sl(0.1), label=5)
     a6 = J(sl(0.1), label=6)
     s1 = Seq(a1, a2)
     s2 = Seq(a3, a4, required=s1)
     s3 = Seq(a5, a6, required=s2)
     sched = Scheduler(s1, s2, s3)
     list_sep(sched, sep + "sequence5")
     self.assertEqual(len(a1.required), 0)
     self.assertEqual(len(a2.required), 1)
     self.assertEqual(len(a3.required), 1)
     self.assertEqual(len(a4.required), 1)
     self.assertEqual(len(a5.required), 1)
     self.assertEqual(len(a6.required), 1)
     self.assertTrue(check_required_types(sched, "test_sequence5"))
     self.assertTrue(sched.orchestrate())
Пример #6
0
 def test_sequence2(self):
     "a job and a sequence"
     a1 = J(sl(0.1), label=1)
     a2 = J(sl(0.1), label=2)
     a3 = J(sl(0.1), label=3)
     s = Seq(a2, a3, required=a1)
     sched = Scheduler(a1, s)
     list_sep(sched, sep + "sequence2")
     self.assertEqual(len(a1.required), 0)
     self.assertEqual(len(a2.required), 1)
     self.assertEqual(len(a3.required), 1)
     self.assertTrue(check_required_types(sched, "test_sequence2"))
     self.assertTrue(sched.orchestrate())
Пример #7
0
 def test_sequence1(self):
     "a simple sequence"
     a1 = J(sl(0.1), label=1)
     a2 = J(sl(0.1), label=2)
     a3 = J(sl(0.1), label=3)
     s = Seq(a1, a2, a3)
     sched = PureScheduler(s)
     list_sep(sched, common_sep + "sequence1")
     self.assertEqual(len(a1.required), 0)
     self.assertEqual(len(a2.required), 1)
     self.assertEqual(len(a3.required), 1)
     self.assertTrue(check_required_types(sched, "test_sequence1"))
     self.assertTrue(sched.run())
Пример #8
0
 def test_sequence3(self):
     "a sequence and a job"
     a1 = J(sl(0.1), label=1)
     a2 = J(sl(0.1), label=2)
     s = Seq(a1, a2)
     a3 = J(sl(0.1), label=3, required=s)
     sched = Scheduler()
     sched.update((s, a3))
     list_sep(sched, sep + "sequence3")
     self.assertEqual(len(a1.required), 0)
     self.assertEqual(len(a2.required), 1)
     self.assertEqual(len(a3.required), 1)
     self.assertTrue(check_required_types(sched, "test_sequence3"))
     self.assertTrue(sched.orchestrate())
Пример #9
0
 def test_loop(self):
     s = Scheduler()
     Seq(J(sl(.1)), J(sl(.2)),
         scheduler=s)
     loop = asyncio.get_event_loop()
     self.assertTrue(s.orchestrate(loop=loop))
Пример #10
0
 def test_seq(self):
     s = PureScheduler()
     Seq(J(sl(.1)), J(sl(.2)), scheduler=s)
     self.assertTrue(s.run())