Пример #1
0
def testTodoDisplayPosition():
    todo = put("Todo", u"TESTDESCRIPTION")
    another_todo = put("Todo", u"TESTDESCRIPTION")
    initial_dp_components = todo["display_position"].split(u".")
    another_dp_components = another_todo["display_position"].split(u".")
    assert len(initial_dp_components) == len(another_dp_components)
    assert int(initial_dp_components[0]) + 1 == int(another_dp_components[0])
    for i in xrange(1, len(initial_dp_components)):
        assert initial_dp_components[i] == another_dp_components[i]
Пример #2
0
def testTodoFilterBy():
    completed_todos = get("Todo", filter_by={"state": u"completed"})
    todo = put("Todo", u"TESTDESCRIPTION")
    set_completed(todo)
    assert todo["state"] == u"completed"
    new_completed_todos = get("Todo", filter_by={"state": u"completed"})
    assert len(new_completed_todos) - len(completed_todos) == 1
Пример #3
0
def testTodoCommit():
    todos = get("Todo", all=True)
    for todo in todos:
        delete_from_db(todo)
        del todo
    commit()
    todos = get("Todo", all=True)
    assert len(todos) == 0
    todo = put("Todo", u"TESTDESCRIPTION")
    commit()
    del todo
    todos = get("Todo", all=True)
    assert len(todos) == 1
    assert todos[0]["description"] == u"TESTDESCRIPTION"
Пример #4
0
def create(request):
    model_type = request.matchdict['model_type']
    primary_descriptor = None
    if model_type == 'todos':
        model_type = 'Todo'
        primary_descriptor = 'description'
    elif model_type == 'projects':
        model_type = 'Project'
        primary_descriptor = 'description'
    elif model_type == 'tags':
        model_type = 'Tag'
        primary_descriptor = 'name'

    new_thing = b.put(model_type, request.json_body[primary_descriptor])
    return json.dumps(b.get(model_type, filter_by={'id': new_thing['id']}), default=datetime_handler)
Пример #5
0
def testTodoDisplayPositionDefined():
    todo = put("Todo", u"TESTDESCRIPTION", u"1.1")
    todo["display_position"] == u"1.1"