Example #1
0
    def test_group_size_hint_max(self):
        strategy = 'max'

        methods = ['1', '2', '3']
        expected = 12
        val = GroupSizeHint.strategy(self.g1, methods, strategy)
        self.assertEqual(
            val, expected,
            "Strategy '{}' for {} and methods {} should return {}".format(
                strategy, self.g1, methods, expected))

        val = GroupSizeHint.strategy(self.g1, ['non', 'existing'], strategy)
        self.assertIsNone(val,
                          "If no hints are available None should be returned")

        methods = ['1', '2', '3']
        expected = 0
        val = GroupSizeHint.strategy(self.g2, methods, strategy)
        self.assertEqual(
            val, expected,
            "Strategy '{}' for {} and methods {} should return {}".format(
                strategy,
                self.g2,
                methods,
                expected,
            ))
Example #2
0
    def test_group_size_hint_first_not_zero(self):
        strategy = 'first-non-zero'

        methods = ['1', '2', '3']
        expected = 10
        val = GroupSizeHint.strategy(self.g1, methods, strategy)
        self.assertEqual(
            val, expected,
            "Strategy '{}' for {} and methods {} should return {}".format(
                strategy, self.g1, methods, expected))

        methods = ['1', '2', '3']
        val = GroupSizeHint.strategy(self.g2, methods, strategy)
        self.assertIsNone(val,
                          "If no hints are available None should be returned")
Example #3
0
 def test_group_size_hint_incorrect_strategy(self):
     with self.assertRaises(KeyError):
         GroupSizeHint.strategy(self.g1, ["unknown"], 'Weird strategy name')