Example #1
0
 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],
     }
Example #2
0
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,
    }
Example #4
0
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,
    }
Example #5
0
def _serialize(ctx: rest.Context,
               category: model.TagCategory) -> rest.Response:
    return tag_categories.serialize_category(
        category, options=serialization.get_serialization_options(ctx))
Example #6
0
def test_serialize_category_when_empty():
    assert tag_categories.serialize_category(None, None) is None
Example #7
0
def test_serialize_category_when_empty():
    assert tag_categories.serialize_category(None, None) is None
Example #8
0
def _serialize(ctx, category):
    return tag_categories.serialize_category(
        category, options=util.get_serialization_options(ctx))
Example #9
0
def _serialize(
        ctx: rest.Context, category: model.TagCategory) -> rest.Response:
    return tag_categories.serialize_category(
        category, options=serialization.get_serialization_options(ctx))