def test_success(self): # set up class WindowDevice(AbstractDevice): @Solution('thermometer.too_high') def open_for_cooling(self): pass @open_for_cooling.evaluator def check_open(self): return 100 class FanDevice(AbstractDevice): @Solution('thermometer.too_high') def open_for_cooling(self): pass @open_for_cooling.evaluator def check_open(self): return 50 # test solutions = [ WindowDevice().open_for_cooling, FanDevice().open_for_cooling ] with self.mysql.dao.SessionContext(): best = worker._find_best_solution(solutions) self.assertEqual('window.open_for_cooling', best.full_name())
def test_success(self): # set up class WindowDevice(AbstractDevice): @Solution("thermometer.too_high") def open_for_cooling(self): pass @open_for_cooling.evaluator def check_open(self): return 100 class FanDevice(AbstractDevice): @Solution("thermometer.too_high") def open_for_cooling(self): pass @open_for_cooling.evaluator def check_open(self): return 50 # test solutions = [WindowDevice().open_for_cooling, FanDevice().open_for_cooling] with self.mysql.dao.SessionContext(): best = worker._find_best_solution(solutions) self.assertEqual("window.open_for_cooling", best.full_name())
def test_no_fit(self): # set up class WindowDevice(AbstractDevice): @Solution('thermometer.too_high') def open_for_cooling(self): pass @open_for_cooling.evaluator def check_open(self): return 0 # test solutions = [WindowDevice().open_for_cooling] with self.mysql.dao.SessionContext(): best = worker._find_best_solution(solutions) self.assertIsNone(best)
def test_no_fit(self): # set up class WindowDevice(AbstractDevice): @Solution("thermometer.too_high") def open_for_cooling(self): pass @open_for_cooling.evaluator def check_open(self): return 0 # test solutions = [WindowDevice().open_for_cooling] with self.mysql.dao.SessionContext(): best = worker._find_best_solution(solutions) self.assertIsNone(best)