Esempio n. 1
0
 def test_result(self):
     sla1 = iteration_time.IterationTime(42)
     sla2 = iteration_time.IterationTime(3.62)
     for sla in [sla1, sla2]:
         sla.add_iteration({"duration": 3.14})
         sla.add_iteration({"duration": 6.28})
     self.assertTrue(sla1.result()["success"])  # 42 > 6.28
     self.assertFalse(sla2.result()["success"])  # 3.62 < 6.28
     self.assertEqual("Passed", sla1.status())
     self.assertEqual("Failed", sla2.status())
Esempio n. 2
0
 def test_add_iteration(self):
     sla = iteration_time.IterationTime(4.0)
     self.assertTrue(sla.add_iteration({"duration": 3.14}))
     self.assertTrue(sla.add_iteration({"duration": 2.0}))
     self.assertTrue(sla.add_iteration({"duration": 3.99}))
     self.assertFalse(sla.add_iteration({"duration": 4.5}))
     self.assertFalse(sla.add_iteration({"duration": 3.8}))
Esempio n. 3
0
    def test_merge(self, durations):

        single_sla = iteration_time.IterationTime(4.0)

        for dd in durations:
            for d in dd:
                single_sla.add_iteration({"duration": d})

        slas = [iteration_time.IterationTime(4.0) for _ in durations]

        for idx, sla in enumerate(slas):
            for duration in durations[idx]:
                sla.add_iteration({"duration": duration})

        merged_sla = slas[0]
        for sla in slas[1:]:
            merged_sla.merge(sla)

        self.assertEqual(single_sla.success, merged_sla.success)
        self.assertEqual(single_sla.max_iteration_time,
                         merged_sla.max_iteration_time)
Esempio n. 4
0
 def test_result_no_iterations(self):
     sla = iteration_time.IterationTime(42)
     self.assertTrue(sla.result()["success"])