Пример #1
0
    def _parse_values(self, data, path):
        values = []
        if isinstance(data, list):
            values = [each for each in data]

        elif isinstance(data, dict):
            minimum = None
            maximum = None
            coverage = None
            for key, item in data.items():
                if key == Keys.RANGE:
                    minimum = min(item)
                    maximum = max(item)
                elif key == Keys.COVERAGE:
                    if not isinstance(item, int):
                        self._wrong_type(int, type(item), *(path + [key]))
                        continue
                    coverage = item
                else:
                    self._ignore(*(path + [key]))

            if minimum is None or maximum is None:
                self._missing([Keys.RANGE], *path)

            elif not coverage:
                self._missing([Keys.COVERAGE], *path)

            else:
                values = Variable.cover(minimum, maximum, coverage)

        else:
            self._wrong_type(dict, type(item), *path)

        return values
Пример #2
0
    def test_given_a_coverage_way_above_the_maximum_coverage(self):
        values = Variable.cover(0, 6, 12)

        self._assertItemsEqual([0, 6], values)
Пример #3
0
    def test_given_the_minimum_coverage(self):
        values = Variable.cover(0, 6, 1)

        self._assertItemsEqual([0, 1, 2, 3, 4, 5, 6], values)
Пример #4
0
    def test_given_a_coverage_that_is_not_a_natural_divisor(self):
        values = Variable.cover(0, 6, 4)

        self._assertItemsEqual([0, 3, 6], values)
Пример #5
0
    def test_given_the_maximum_coverage(self):
        values = Variable.cover(0, 6, 6)

        self.assertItemsEqual([0, 6], values)