def get(self, ctx): auth.verify_privilege(ctx.user, 'tag_categories:list') categories = tag_categories.get_all_categories() return { 'results': [ tag_categories.serialize_category(category) \ for category in categories], }
def test_serialize_category(tag_category_factory, tag_factory): category = tag_category_factory(name='name', color='color') category.category_id = 1 category.default = True tag1 = tag_factory(category=category) tag2 = tag_factory(category=category) db.session.add_all([category, tag1, tag2]) db.session.flush() result = tag_categories.serialize_category(category) assert result == { 'name': 'name', 'color': 'color', 'default': True, 'version': 1, 'usages': 2, }
def test_serialize_category(tag_category_factory, tag_factory): category = tag_category_factory(name='name', color='color') category.category_id = 1 category.default = True tag1 = tag_factory(category=category) tag2 = tag_factory(category=category) db.session.add_all([category, tag1, tag2]) db.session.flush() result = tag_categories.serialize_category(category) assert result == { 'name': 'name', 'color': 'color', 'default': True, 'version': 1, 'usages': 2, }
def test_serialize_category(tag_category_factory, tag_factory): category = tag_category_factory(name="name", color="color") category.category_id = 1 category.default = True tag1 = tag_factory(category=category) tag2 = tag_factory(category=category) db.session.add_all([category, tag1, tag2]) db.session.flush() result = tag_categories.serialize_category(category) assert result == { "name": "name", "color": "color", "default": True, "version": 1, "order": 1, "usages": 2, }
def _serialize(ctx: rest.Context, category: model.TagCategory) -> rest.Response: return tag_categories.serialize_category( category, options=serialization.get_serialization_options(ctx))
def test_serialize_category_when_empty(): assert tag_categories.serialize_category(None, None) is None
def test_serialize_category_when_empty(): assert tag_categories.serialize_category(None, None) is None
def _serialize(ctx, category): return tag_categories.serialize_category( category, options=util.get_serialization_options(ctx))
def _serialize( ctx: rest.Context, category: model.TagCategory) -> rest.Response: return tag_categories.serialize_category( category, options=serialization.get_serialization_options(ctx))