Esempio n. 1
0
    def test_get_min_accepted_performance(self):
        # given
        p = Performance(environment_id=Environment.get_id(),
                        min_accepted_step=100)
        p.save()
        MinPerformanceMultiplier.set(3.141)

        # then
        self.assertEqual(MinPerformanceMultiplier.get(), 3.141)
        self.assertEqual(self.env.get_min_accepted_performance(), 314.1)
Esempio n. 2
0
    def get_min_accepted_performance(cls) -> float:
        """ Return minimal accepted performance for the environment.
        :return float:
        """
        step: float = 300
        try:
            perf = Performance.get(Performance.environment_id == cls.get_id())
            step = perf.min_accepted_step
        except Performance.DoesNotExist:
            pass

        return step * MinPerformanceMultiplier.get()
Esempio n. 3
0
 def test_get_min_accepted_performance_default(self):
     self.assertEqual(MinPerformanceMultiplier.get(), 0.0)
     self.assertEqual(self.env.get_min_accepted_performance(), 0.0)
 def test_above_max(self):
     with self.assertRaisesRegex(Exception, 'must be within'):
         MinPerformanceMultiplier.set(self.max + 2)
 def test_below_min(self):
     with self.assertRaisesRegex(Exception, 'must be within'):
         MinPerformanceMultiplier.set(self.min - 1)
 def test_max(self):
     MinPerformanceMultiplier.set(self.max)
     self.assertEqual(self.max, MinPerformanceMultiplier.get())
 def test_fractional(self):
     MinPerformanceMultiplier.set(3.1415)
     self.assertEqual(3.1415, MinPerformanceMultiplier.get())
 def test_min(self):
     MinPerformanceMultiplier.set(self.min)
     self.assertEqual(self.min, MinPerformanceMultiplier.get())
 def test_zero_when_not_set(self):
     self.assertEqual(0, MinPerformanceMultiplier.get())