Exemplo n.º 1
0
    def _find_unsaved_children(cls, obj, children, files):
        def callback(o):
            if isinstance(o, Object):
                if o.is_dirty():
                    children.append(o)
                return

            if isinstance(o, leancloud.File):
                if not o.url or not o.id:
                    files.append(o)
                return

        utils.traverse_object(obj, callback)
Exemplo n.º 2
0
    def _find_unsaved_children(cls, obj, children, files):

        def callback(o):
            if isinstance(o, Object):
                if o.is_dirty():
                    children.append(o)
                return

            if isinstance(o, leancloud.File):
                if o.url is None and o.id is None:
                    files.append(o)
                return

        utils.traverse_object(obj, callback)
Exemplo n.º 3
0
def test_util():  # type: () -> None
    obj = Object.extend("Foo")()

    def callback(o):
        callback.count += 1
        if callback.count == 1:
            assert o == {}
        elif callback.count == 2:
            assert o == obj

    callback.count = 0

    utils.traverse_object(obj, callback)

    assert callback.count == 2
Exemplo n.º 4
0
def test_util():
    obj = Object.extend('Foo')()

    def callback(o):
        callback.count += 1
        if callback.count == 1:
            assert o == {}
        elif callback.count == 2:
            assert o == obj

    callback.count = 0

    utils.traverse_object(obj, callback)

    assert callback.count == 2