Exemple #1
0
    def test_group_apis_to_dict(self):
        context = {"model": model, "session": model.Session}
        api_group = {
            "name": u"testgroup",
            "title": u"Some Group Title",
            "description": u"Great group!",
            "packages": [u"annakarenina", u"warandpeace"],
        }

        assert group_api_to_dict(api_group, context) == {
            "description": u"Great group!",
            "name": u"testgroup",
            "packages": [{"id": u"annakarenina"}, {"id": u"warandpeace"}],
            "title": u"Some Group Title",
        }, pformat(group_api_to_dict(api_group, context))
Exemple #2
0
    def test_17_group_apis_to_dict(self):

        context = {"model": model, "session": model.Session}

        api_group = {
            "name": u"testgroup",
            "title": u"Some Group Title",
            "description": u"Great group!",
            "packages": [u"annakarenina", u"warandpeace"],
        }

        assert group_api_to_dict(api_group, context) == {
            "description": u"Great group!",
            "name": u"testgroup",
            "packages": [{"id": u"annakarenina"}, {"id": u"warandpeace"}],
            "title": u"Some Group Title",
        }, pformat(group_api_to_dict(api_group, context))
Exemple #3
0
def group_create_rest(context, data_dict):
    _check_access('group_create_rest', context, data_dict)
    dictized_group = model_save.group_api_to_dict(data_dict, context)
    dictized_after = _get_action('group_create')(context, dictized_group)
    group = context['group']
    group_dict = model_dictize.group_to_api(group, context)
    data_dict['id'] = group.id
    return group_dict
Exemple #4
0
def group_create_rest(context, data_dict):
    _check_access("group_create_rest", context, data_dict)
    dictized_group = model_save.group_api_to_dict(data_dict, context)
    dictized_after = _get_action("group_create")(context, dictized_group)
    group = context["group"]
    group_dict = model_dictize.group_to_api(group, context)
    data_dict["id"] = group.id
    return group_dict
Exemple #5
0
def group_create_rest(context, data_dict):
    _check_access('group_create_rest', context, data_dict)
    dictized_group = model_save.group_api_to_dict(data_dict, context)
    dictized_after = _get_action('group_create')(context, dictized_group)
    group = context['group']
    group_dict = model_dictize.group_to_api(group, context)
    data_dict['id'] = group.id
    return group_dict
Exemple #6
0
    def test_17_group_apis_to_dict(self):

        context = {"model": model, "session": model.Session}

        api_group = {
            'name': u'testgroup',
            'title': u'Some Group Title',
            'description': u'Great group!',
            'packages': [u'annakarenina', u'warandpeace'],
        }

        assert group_api_to_dict(api_group, context) == {
            'description': u'Great group!',
            'name': u'testgroup',
            'packages': [{
                'id': u'annakarenina'
            }, {
                'id': u'warandpeace'
            }],
            'title': u'Some Group Title'
        }, pformat(group_api_to_dict(api_group, context))
    def test_17_group_apis_to_dict(self):

        context = {"model": model,
                  "session": model.Session}

        api_group = {
            'name' : u'testgroup',
            'title' : u'Some Group Title',
            'description' : u'Great group!',
            'packages' : [u'annakarenina', u'warandpeace'],
        }


        assert group_api_to_dict(api_group, context) == {'description': u'Great group!',
                                                         'name': u'testgroup',
                                                         'packages': [{'id': u'annakarenina'}, {'id': u'warandpeace'}],
                                                         'title': u'Some Group Title'}, pformat(group_api_to_dict(api_group, context))
Exemple #8
0
def group_create_rest(context, data_dict):

    api = context.get('api_version') or '1'

    dictized_group = group_api_to_dict(data_dict, context)
    dictized_after = group_create(context, dictized_group)

    group = context['group']

    if api == '1':
        group_dict = group_to_api1(group, context)
    else:
        group_dict = group_to_api2(group, context)

    data_dict['id'] = group.id

    return group_dict
Exemple #9
0
def group_create_rest(context, data_dict):

    api = context.get('api_version') or '1'

    dictized_group = group_api_to_dict(data_dict, context)
    dictized_after = group_create(context, dictized_group) 

    group = context['group']

    if api == '1':
        group_dict = group_to_api1(group, context)
    else:
        group_dict = group_to_api2(group, context)

    data_dict['id'] = group.id

    return group_dict
Exemple #10
0
def group_update_rest(context, data_dict):

    model = context['model']
    id = data_dict["id"]
    group = model.Group.get(id)
    context["group"] = group
    context["allow_partial_update"] = True
    dictized_group = model_save.group_api_to_dict(data_dict, context)

    check_access('group_update_rest', context, dictized_group)

    dictized_after = get_action('group_update')(context, dictized_group)

    group = context['group']

    group_dict = model_dictize.group_to_api(group, context)

    return group_dict
Exemple #11
0
def group_update_rest(context, data_dict):

    model = context["model"]
    id = _get_or_bust(data_dict, "id")
    group = model.Group.get(id)
    context["group"] = group
    context["allow_partial_update"] = True
    dictized_group = model_save.group_api_to_dict(data_dict, context)

    _check_access("group_update_rest", context, dictized_group)

    dictized_after = _get_action("group_update")(context, dictized_group)

    group = context["group"]

    group_dict = model_dictize.group_to_api(group, context)

    return group_dict
Exemple #12
0
def group_update_rest(context, data_dict):

    model = context['model']
    id = _get_or_bust(data_dict, "id")
    group = model.Group.get(id)
    context["group"] = group
    context["allow_partial_update"] = True
    dictized_group = model_save.group_api_to_dict(data_dict, context)

    _check_access('group_update_rest', context, dictized_group)

    dictized_after = _get_action('group_update')(context, dictized_group)

    group = context['group']

    group_dict = model_dictize.group_to_api(group, context)

    return group_dict
Exemple #13
0
def group_update_rest(context, data_dict):

    model = context['model']
    id = data_dict["id"]
    api = context.get('api_version') or '1'
    group = model.Group.get(id)
    context["group"] = group
    context["allow_partial_update"] = True
    dictized_package = group_api_to_dict(data_dict, context)
    dictized_after = group_update(context, dictized_package)

    group = context['group']

    if api == '1':
        group_dict = group_to_api1(group, context)
    else:
        group_dict = group_to_api2(group, context)

    return group_dict
Exemple #14
0
def group_update_rest(context, data_dict):

    model = context['model']
    id = data_dict["id"]
    api = context.get('api_version') or '1'
    group = model.Group.get(id)
    context["group"] = group
    context["allow_partial_update"] = True
    dictized_package = group_api_to_dict(data_dict, context)
    dictized_after = group_update(context, dictized_package)

    group = context['group']

    if api == '1':
        group_dict = group_to_api1(group, context)
    else:
        group_dict = group_to_api2(group, context)

    return group_dict
Exemple #15
0
def group_create_rest(context, data_dict):

    api = context.get('api_version') or '1'

    check_access('group_create_rest', context, data_dict)

    dictized_group = model_save.group_api_to_dict(data_dict, context)
    dictized_after = get_action('group_create')(context, dictized_group)

    group = context['group']

    if api == '1':
        group_dict = model_dictize.group_to_api1(group, context)
    else:
        group_dict = model_dictize.group_to_api2(group, context)

    data_dict['id'] = group.id

    return group_dict
Exemple #16
0
def group_create_rest(context, data_dict):

    api = context.get('api_version') or '1'

    check_access('group_create_rest', context, data_dict)

    dictized_group = model_save.group_api_to_dict(data_dict, context)
    dictized_after = get_action('group_create')(context, dictized_group)

    group = context['group']

    if api == '1':
        group_dict = model_dictize.group_to_api1(group, context)
    else:
        group_dict = model_dictize.group_to_api2(group, context)

    data_dict['id'] = group.id

    return group_dict
def group_update_rest(context, data_dict):

    model = context['model']
    id = data_dict["id"]
    api = context.get('api_version') or '1'
    group = model.Group.get(id)
    context["group"] = group
    context["allow_partial_update"] = True
    dictized_group = model_save.group_api_to_dict(data_dict, context)

    check_access('group_update_rest', context, dictized_group)

    dictized_after = get_action('group_update')(context, dictized_group)

    group = context['group']

    if api == '1':
        group_dict = model_dictize.group_to_api1(group, context)
    else:
        group_dict = model_dictize.group_to_api2(group, context)

    return group_dict
Exemple #18
0
def group_update_rest(context, data_dict):

    model = context["model"]
    id = data_dict["id"]
    api = context.get("api_version") or "1"
    group = model.Group.get(id)
    context["group"] = group
    context["allow_partial_update"] = True
    dictized_group = group_api_to_dict(data_dict, context)

    check_access("group_update_rest", context, dictized_group)

    dictized_after = group_update(context, dictized_group)

    group = context["group"]

    if api == "1":
        group_dict = group_to_api1(group, context)
    else:
        group_dict = group_to_api2(group, context)

    return group_dict