@@ -0,0 +1,1852 @@
+# -*- coding: utf8 -*-%0A# This file is part of PyBossa.%0A#%0A# Copyright (C) 2015 SF Isle of Man Limited%0A#%0A# PyBossa is free software: you can redistribute it and/or modify%0A# it under the terms of the GNU Affero General Public License as published by%0A# the Free Software Foundation, either version 3 of the License, or%0A# (at your option) any later version.%0A#%0A# PyBossa is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A# GNU Affero General Public License for more details.%0A#%0A# You should have received a copy of the GNU Affero General Public License%0A# along with PyBossa.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A%0Afrom default import Test%0Afrom pybossa.cache import categories as cached_categories%0Afrom factories import CategoryFactory, ProjectFactory%0A%0A%0Aclass TestCategoriesCache(Test):%0A%0A    def test_get_all_returns_all_categories(self):%0A        categories = %5BCategoryFactory.create()%5D%0A%0A        assert cached_categories.get_all() == categories%0A%0A%0A    def test_get_used_returns_only_categories_with_projects(self):%0A        used_category = CategoryFactory.create()%0A        ProjectFactory.create(category=used_category)%0A        unused_category = CategoryFactory.create()%0A%0A        used_categories = cached_categories.get_used()%0A%0A        assert used_categories%5B0%5D%5B'id'%5D == used_category.id, used_categories%0A%0A%0A    def test_get_used_returns_requiered_fields(self):%0A        used_category = CategoryFactory.create()%0A        ProjectFactory.create(category=used_category)%0A        fields = ('id', 'name', 'short_name', 'description')%0A%0A        used_categories = cached_categories.get_used()%0A%0A        for field in fields:%0A            assert field in used_categories%5B0%5D.keys()%0A        assert len(fields) == len(used_categories%5B0%5D.keys())%0A

Add tests for categories in cache