def index_fixture(self, request):
     categories = Categories()
     categories_ = [
         instance_mock(request, Category, leaf_count=3),
         instance_mock(request, Category, leaf_count=6),
         instance_mock(request, Category, leaf_count=9),
     ]
     category_ = categories_[1]
     expected_value = 3
     categories._categories = categories_
     return categories, category_, expected_value
Beispiel #2
0
 def index_fixture(self, request):
     categories = Categories()
     categories_ = [
         instance_mock(request, Category, leaf_count=3),
         instance_mock(request, Category, leaf_count=6),
         instance_mock(request, Category, leaf_count=9),
     ]
     category_ = categories_[1]
     expected_value = 3
     categories._categories = categories_
     return categories, category_, expected_value
    def levels_fixture(self, request):
        cat_data, expected_value = request.param
        categories = Categories()

        def iter_cats(cat_tree):
            for idx, cat_label, sub_cats in cat_tree:
                category_ = instance_mock(request, Category, idx=idx)
                category_.label = cat_label
                category_.sub_categories = list(iter_cats(sub_cats))
                yield category_

        categories._categories = list(iter_cats(cat_data))

        return categories, expected_value
Beispiel #4
0
    def levels_fixture(self, request):
        cat_data, expected_value = request.param
        categories = Categories()

        def iter_cats(cat_tree):
            for idx, cat_name, sub_cats in cat_tree:
                category_ = instance_mock(request, Category, idx=idx)
                category_.name = cat_name
                category_.sub_categories = list(iter_cats(sub_cats))
                yield category_

        categories._categories = list(iter_cats(cat_data))

        return categories, expected_value