コード例 #1
0
def test_load_from_files_partial(use_testdb, dumpdir):
    os.makedirs(dumpdir)

    with open(os.path.join(dumpdir, 'pdtest1_dump.jsonl'), 'w', encoding='utf-8') as fp:
        fp.write('{"_entity": "pdtest1", "k1": 1, "k2": 2, "k3": 3, "test3": [17]}\n')

    with gzip.open(os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'), 'wt', encoding='utf-8') as fp:
        fp.write('{"_entity": "pdtest2", "id": 1, "test1": [1, 2, 3]}\n')

    with open(os.path.join(dumpdir, 'pdtest3_dump.jsonl'), 'w', encoding='utf-8') as fp:
        fp.write('{"_entity": "pdtest3", "foo_bool": true, "foo_datetime": "2017-06-01T01:02:03.999987Z", "foo_float": 0.30000000000000004, "foo_int": -4, "foo_longstr": "longstr", "foo_string": "foo\\u0000😊bar", "foo_uuid": "8e8cdc11-0785-43a8-8203-66c148c3f57c", "id": 17}\n')

    with open(os.path.join(dumpdir, 'many1_dump.jsonl'), 'w', encoding='utf-8') as fp:
        fp.write('{"_entity": "many1", "id": 1, "many2": [1, 2]}\n')
        fp.write('{"_entity": "many1", "id": 2}\n')

    with open(os.path.join(dumpdir, 'many2_dump.jsonl'), 'w', encoding='utf-8') as fp:
        fp.write('{"_entity": "many2", "id": 1, "many1": [1, 2]}\n')
        fp.write('{"_entity": "many2", "id": 2, "many1": [1, 2]}\n')

    pd = PonyDump(testdb)

    for _ in pd.load_from_files([dumpdir]):
        pass

    assert not pd.get_depcache_dict()

    assert PDTest1.select().count() == 1

    test1 = PDTest1.select().first()
    assert test1.get_pk() == (1, 2, 3)
    assert test1.test2.id == 1
    assert test1.test3.select().count() == 1
    assert test1.test3.select().first().id == 17

    assert PDTest2.select().count() == 1
    test2 = PDTest2.select().first()
    assert test2.get_pk() == 1
    assert test2.test1 is test1  # Pony ORM кэширует всё подряд, поэтому можно is

    assert PDTest3.select().count() == 1
    test3 = PDTest3.select().first()
    assert test3.get_pk() == 17
    assert test3.test1 is test1

    many1_1, many1_2 = Many1.select().order_by(Many1.id)[:]
    many2_1, many2_2 = Many2.select().order_by(Many2.id)[:]

    assert many1_1.many2.select().order_by(Many2.id)[:] == [many2_1, many2_2]
    assert many1_2.many2.select().order_by(Many2.id)[:] == [many2_1, many2_2]
    assert many2_1.many1.select().order_by(Many1.id)[:] == [many1_1, many1_2]
    assert many2_2.many1.select().order_by(Many1.id)[:] == [many1_1, many1_2]
コード例 #2
0
ファイル: test_ponydump.py プロジェクト: ra2003/mini_fiction
def test_load_from_files_notfull(use_testdb, dumpdir):
    os.makedirs(dumpdir)

    with open(os.path.join(dumpdir, 'pdtest1_dump.jsonl'),
              'w',
              encoding='utf-8') as fp:
        fp.write(
            '{"_entity": "pdtest1", "k1": 1, "k2": 2, "k3": 3, "test2": 12, "test3": [17, 19]}\n'
        )

    pd = PonyDump(testdb)

    for _ in pd.load_from_files([dumpdir]):
        pass

    depcache = pd.get_depcache_dict()
    assert depcache

    assert PDTest1.select().count() == 1

    test1 = PDTest1.select().first()
    assert test1.get_pk() == (1, 2, 3)
    assert not test1.test2
    assert test1.test3.select().count() == 0

    assert PDTest2.select().count() == 0
    assert PDTest3.select().count() == 0

    key = (('pdtest1', 'test2'), ('pdtest2', 'test1'))
    assert key in depcache
    assert depcache[key] == [
        {
            (1, 2, 3): {(12, )},
        },
        {
            (12, ): {(1, 2, 3)},
        },
    ]

    key = (('pdtest1', 'test3'), ('pdtest3', 'test1'))
    assert key in depcache
    assert depcache[key] == [{
        (1, 2, 3): {(19, ), (17, )}
    }, {
        (19, ): {(1, 2, 3)},
        (17, ): {(1, 2, 3)},
    }]
コード例 #3
0
def test_load_from_files_notfull(use_testdb, dumpdir):
    os.makedirs(dumpdir)

    with open(os.path.join(dumpdir, 'pdtest1_dump.jsonl'), 'w', encoding='utf-8') as fp:
        fp.write('{"_entity": "pdtest1", "k1": 1, "k2": 2, "k3": 3, "test2": 12, "test3": [17, 19]}\n')

    pd = PonyDump(testdb)

    for _ in pd.load_from_files([dumpdir]):
        pass

    depcache = pd.get_depcache_dict()
    assert depcache

    assert PDTest1.select().count() == 1

    test1 = PDTest1.select().first()
    assert test1.get_pk() == (1, 2, 3)
    assert not test1.test2
    assert test1.test3.select().count() == 0

    assert PDTest2.select().count() == 0
    assert PDTest3.select().count() == 0

    key = (('pdtest1', 'test2'), ('pdtest2', 'test1'))
    assert key in depcache
    assert depcache[key] == [
        {
            (1, 2, 3): {(12,)},
        },
        {
            (12,): {(1, 2, 3)},
        },
    ]

    key = (('pdtest1', 'test3'), ('pdtest3', 'test1'))
    assert key in depcache
    assert depcache[key] == [
        {
            (1, 2, 3): {(19,), (17,)}
        },
        {
            (19,): {(1, 2, 3)},
            (17,): {(1, 2, 3)},
        }
    ]
コード例 #4
0
def test_load_from_files_relations_all_orders(use_testdb, dumpdir, lines):
    os.makedirs(dumpdir)

    with open(os.path.join(dumpdir, 'some_dump.jsonl'), 'w', encoding='utf-8') as fp:
        for line in lines:
            fp.write(line + '\n')

    pd = PonyDump(testdb)

    for _ in pd.load_from_files([dumpdir]):
        pass

    assert not pd.get_depcache_dict()

    many1 = Many1.select().first()
    many2 = Many2.select().first()

    assert many1.many2.select()[:] == [many2]
    assert many2.many1.select()[:] == [many1]
コード例 #5
0
ファイル: test_ponydump.py プロジェクト: ra2003/mini_fiction
def test_load_from_files_relations_all_orders(use_testdb, dumpdir, lines):
    os.makedirs(dumpdir)

    with open(os.path.join(dumpdir, 'some_dump.jsonl'), 'w',
              encoding='utf-8') as fp:
        for line in lines:
            fp.write(line + '\n')

    pd = PonyDump(testdb)

    for _ in pd.load_from_files([dumpdir]):
        pass

    assert not pd.get_depcache_dict()

    many1 = Many1.select().first()
    many2 = Many2.select().first()

    assert many1.many2.select()[:] == [many2]
    assert many2.many1.select()[:] == [many1]
コード例 #6
0
ファイル: test_ponydump.py プロジェクト: ra2003/mini_fiction
def test_load_from_files_partial(use_testdb, dumpdir):
    os.makedirs(dumpdir)

    with open(os.path.join(dumpdir, 'pdtest1_dump.jsonl'),
              'w',
              encoding='utf-8') as fp:
        fp.write(
            '{"_entity": "pdtest1", "k1": 1, "k2": 2, "k3": 3, "test3": [17]}\n'
        )

    with gzip.open(os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'),
                   'wt',
                   encoding='utf-8') as fp:
        fp.write('{"_entity": "pdtest2", "id": 1, "test1": [1, 2, 3]}\n')

    with open(os.path.join(dumpdir, 'pdtest3_dump.jsonl'),
              'w',
              encoding='utf-8') as fp:
        fp.write(
            '{"_entity": "pdtest3", "foo_bool": true, "foo_datetime": "2017-06-01T01:02:03.999987Z", "foo_float": 0.30000000000000004, "foo_int": -4, "foo_longstr": "longstr", "foo_string": "foo\\u0000😊bar", "foo_uuid": "8e8cdc11-0785-43a8-8203-66c148c3f57c", "id": 17}\n'
        )

    with open(os.path.join(dumpdir, 'many1_dump.jsonl'), 'w',
              encoding='utf-8') as fp:
        fp.write('{"_entity": "many1", "id": 1, "many2": [1, 2]}\n')
        fp.write('{"_entity": "many1", "id": 2}\n')

    with open(os.path.join(dumpdir, 'many2_dump.jsonl'), 'w',
              encoding='utf-8') as fp:
        fp.write('{"_entity": "many2", "id": 1, "many1": [1, 2]}\n')
        fp.write('{"_entity": "many2", "id": 2, "many1": [1, 2]}\n')

    pd = PonyDump(testdb)

    for _ in pd.load_from_files([dumpdir]):
        pass

    assert not pd.get_depcache_dict()

    assert PDTest1.select().count() == 1

    test1 = PDTest1.select().first()
    assert test1.get_pk() == (1, 2, 3)
    assert test1.test2.id == 1
    assert test1.test3.select().count() == 1
    assert test1.test3.select().first().id == 17

    assert PDTest2.select().count() == 1
    test2 = PDTest2.select().first()
    assert test2.get_pk() == 1
    assert test2.test1 is test1  # Pony ORM кэширует всё подряд, поэтому можно is

    assert PDTest3.select().count() == 1
    test3 = PDTest3.select().first()
    assert test3.get_pk() == 17
    assert test3.test1 is test1

    many1_1, many1_2 = Many1.select().order_by(Many1.id)[:]
    many2_1, many2_2 = Many2.select().order_by(Many2.id)[:]

    assert many1_1.many2.select().order_by(Many2.id)[:] == [many2_1, many2_2]
    assert many1_2.many2.select().order_by(Many2.id)[:] == [many2_1, many2_2]
    assert many2_1.many1.select().order_by(Many1.id)[:] == [many1_1, many1_2]
    assert many2_2.many1.select().order_by(Many1.id)[:] == [many1_1, many1_2]
コード例 #7
0
ファイル: test_ponydump.py プロジェクト: ra2003/mini_fiction
def test_load_from_files_full(use_testdb, dumpdir):
    os.makedirs(dumpdir)

    with open(os.path.join(dumpdir, 'pdtest1_dump.jsonl'),
              'w',
              encoding='utf-8') as fp:
        fp.write(
            '{"_entity": "pdtest1", "k1": 1, "k2": 2, "k3": 3, "test2": 1, "test3": [17]}\n'
        )

    with gzip.open(os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'),
                   'wt',
                   encoding='utf-8') as fp:
        fp.write('{"_entity": "pdtest2", "id": 1, "test1": [1, 2, 3]}\n')

    with open(os.path.join(dumpdir, 'pdtest3_dump.jsonl'),
              'w',
              encoding='utf-8') as fp:
        fp.write(
            '{"_entity": "pdtest3", "foo_bool": true, "foo_datetime": "2017-06-01T01:02:03.999987Z", "foo_float": 0.30000000000000004, "foo_int": -4, "foo_longstr": "longstr", "foo_string": "foo\\u0000😊bar", "foo_uuid": "8e8cdc11-0785-43a8-8203-66c148c3f57c", "id": 17, "test1": [1, 2, 3]}\n'
        )

    with open(os.path.join(dumpdir, 'many1_dump.jsonl'), 'w',
              encoding='utf-8') as fp:
        fp.write('{"_entity": "many1", "id": 1, "many2": [1, 2]}\n')
        fp.write('{"_entity": "many1", "id": 2, "many2": [1, 2]}\n')

    with open(os.path.join(dumpdir, 'many2_dump.jsonl'), 'w',
              encoding='utf-8') as fp:
        fp.write('{"_entity": "many2", "id": 1, "many1": [1, 2]}\n')
        fp.write('{"_entity": "many2", "id": 2, "many1": [1, 2]}\n')

    pd = PonyDump(testdb)

    # create test

    load_statuses = [
        {
            'created': True,
            'updated': True,
            'entity': 'many1',
            'pk': 1,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'many1_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'created': True,
            'updated': True,
            'entity': 'many1',
            'pk': 2,
            'lineno': 2,
            'current': 2,
            'path': os.path.join(dumpdir, 'many1_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 2,
            'current': 2,
            'path': os.path.join(dumpdir, 'many1_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'created': True,
            'updated': True,
            'entity': 'many2',
            'pk': 1,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'many2_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'created': True,
            'updated': True,
            'entity': 'many2',
            'pk': 2,
            'lineno': 2,
            'current': 2,
            'path': os.path.join(dumpdir, 'many2_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 2,
            'current': 2,
            'path': os.path.join(dumpdir, 'many2_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'created': True,
            'updated': True,
            'entity': 'pdtest1',
            'pk': (1, 2, 3),
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest1_dump.jsonl'),
            'count': 1,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest1_dump.jsonl'),
            'count': 1,
            'all_count': 7
        },
        {
            'created': True,
            'updated': True,
            'entity': 'pdtest3',
            'pk': 17,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest3_dump.jsonl'),
            'count': 1,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest3_dump.jsonl'),
            'count': 1,
            'all_count': 7
        },
        {
            'created': True,
            'updated': True,
            'entity': 'pdtest2',
            'pk': 1,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'),
            'count': 1,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'),
            'count': 1,
            'all_count': 7
        },
        {
            'path': None,
            'entity': None,
            'pk': None,
            'updated': None,
            'created': None,
            'count': 7,
            'all_count': 7
        },
    ]

    for statuses in pd.load_from_files([dumpdir]):
        for status in statuses:
            assert status in load_statuses
            load_statuses.remove(status)

    assert not load_statuses
    assert not pd.get_depcache_dict()

    # update test
    PDTest3.select().first().foo_longstr = 'changed string'
    Many2.get(id=2).delete()

    load_statuses = [
        # updated=False, потому что зависимость Many2(2) ещё отсутствует в базе
        {
            'created': False,
            'updated': False,
            'entity': 'many1',
            'pk': 1,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'many1_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'created': False,
            'updated': False,
            'entity': 'many1',
            'pk': 2,
            'lineno': 2,
            'current': 2,
            'path': os.path.join(dumpdir, 'many1_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 2,
            'current': 2,
            'path': os.path.join(dumpdir, 'many1_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'created': False,
            'updated': False,
            'entity': 'many2',
            'pk': 1,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'many2_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        # ...и создаётся только сейчас
        {
            'created': True,
            'updated': True,
            'entity': 'many2',
            'pk': 2,
            'lineno': 2,
            'current': 2,
            'path': os.path.join(dumpdir, 'many2_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 2,
            'current': 2,
            'path': os.path.join(dumpdir, 'many2_dump.jsonl'),
            'count': 2,
            'all_count': 7
        },
        {
            'created': False,
            'updated': False,
            'entity': 'pdtest1',
            'pk': (1, 2, 3),
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest1_dump.jsonl'),
            'count': 1,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest1_dump.jsonl'),
            'count': 1,
            'all_count': 7
        },
        # Ещё вот тут мы меняли атрибут
        {
            'created': False,
            'updated': True,
            'entity': 'pdtest3',
            'pk': 17,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest3_dump.jsonl'),
            'count': 1,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest3_dump.jsonl'),
            'count': 1,
            'all_count': 7
        },
        {
            'created': False,
            'updated': False,
            'entity': 'pdtest2',
            'pk': 1,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'),
            'count': 1,
            'all_count': 7
        },
        {
            'entity': None,
            'updated': None,
            'created': None,
            'pk': None,
            'lineno': 1,
            'current': 1,
            'path': os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'),
            'count': 1,
            'all_count': 7
        },
        {
            'path': None,
            'entity': None,
            'pk': None,
            'updated': None,
            'created': None,
            'count': 7,
            'all_count': 7
        },
    ]

    for statuses in pd.load_from_files([dumpdir]):
        for status in statuses:
            load_statuses.remove(status)
            if status['entity'] == 'many1':
                # Проверяем, что отсутствующая зависимость Many2 положена в depcache
                deps = pd.get_depcache_dict()[(('many1', 'many2'), ('many2',
                                                                    'many1'))]
                assert (2, ) in deps[0].get((status['pk'], ))
                assert (status['pk'], ) in deps[1].get((2, ))

    assert not load_statuses
    assert not pd.get_depcache_dict()

    assert PDTest1.select().count() == 1

    test1 = PDTest1.select().first()
    assert test1.get_pk() == (1, 2, 3)
    assert test1.test2.id == 1
    assert test1.test3.select().count() == 1
    assert test1.test3.select().first().id == 17

    assert PDTest2.select().count() == 1
    test2 = PDTest2.select().first()
    assert test2.get_pk() == 1
    assert test2.test1 is test1  # Pony ORM кэширует всё подряд, поэтому можно is

    assert PDTest3.select().count() == 1
    test3 = PDTest3.select().first()
    assert test3.get_pk() == 17
    assert test3.test1 is test1

    assert test3.foo_bool is True
    assert test3.foo_int == -4
    assert 0.1 + 0.2 == 0.30000000000000004
    assert test3.foo_float == 0.30000000000000004
    assert test3.foo_string == 'foo\u0000😊bar'
    assert test3.foo_longstr == 'longstr'
    assert test3.foo_datetime == datetime(2017, 6, 1, 1, 2, 3, 999987)
    assert test3.foo_uuid == uuid.UUID('8e8cdc11-0785-43a8-8203-66c148c3f57c')

    many1_1, many1_2 = Many1.select().order_by(Many1.id)[:]
    many2_1, many2_2 = Many2.select().order_by(Many2.id)[:]

    assert many1_1.many2.select().order_by(Many2.id)[:] == [many2_1, many2_2]
    assert many1_2.many2.select().order_by(Many2.id)[:] == [many2_1, many2_2]
    assert many2_1.many1.select().order_by(Many1.id)[:] == [many1_1, many1_2]
    assert many2_2.many1.select().order_by(Many1.id)[:] == [many1_1, many1_2]
コード例 #8
0
def test_load_from_files_full(use_testdb, dumpdir):
    os.makedirs(dumpdir)

    with open(os.path.join(dumpdir, 'pdtest1_dump.jsonl'), 'w', encoding='utf-8') as fp:
        fp.write('{"_entity": "pdtest1", "k1": 1, "k2": 2, "k3": 3, "test2": 1, "test3": [17]}\n')

    with gzip.open(os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'), 'wt', encoding='utf-8') as fp:
        fp.write('{"_entity": "pdtest2", "id": 1, "test1": [1, 2, 3]}\n')

    with open(os.path.join(dumpdir, 'pdtest3_dump.jsonl'), 'w', encoding='utf-8') as fp:
        fp.write('{"_entity": "pdtest3", "foo_bool": true, "foo_datetime": "2017-06-01T01:02:03.999987Z", "foo_float": 0.30000000000000004, "foo_int": -4, "foo_longstr": "longstr", "foo_string": "foo\\u0000😊bar", "foo_uuid": "8e8cdc11-0785-43a8-8203-66c148c3f57c", "id": 17, "test1": [1, 2, 3]}\n')

    with open(os.path.join(dumpdir, 'many1_dump.jsonl'), 'w', encoding='utf-8') as fp:
        fp.write('{"_entity": "many1", "id": 1, "many2": [1, 2]}\n')
        fp.write('{"_entity": "many1", "id": 2, "many2": [1, 2]}\n')

    with open(os.path.join(dumpdir, 'many2_dump.jsonl'), 'w', encoding='utf-8') as fp:
        fp.write('{"_entity": "many2", "id": 1, "many1": [1, 2]}\n')
        fp.write('{"_entity": "many2", "id": 2, "many1": [1, 2]}\n')

    pd = PonyDump(testdb)

    # create test

    load_statuses = [
        {'created': True, 'updated': True, 'entity': 'many1', 'pk': 1, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'many1_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'created': True, 'updated': True, 'entity': 'many1', 'pk': 2, 'lineno': 2, 'current': 2, 'path': os.path.join(dumpdir, 'many1_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 2, 'current': 2, 'path': os.path.join(dumpdir, 'many1_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'created': True, 'updated': True, 'entity': 'many2', 'pk': 1, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'many2_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'created': True, 'updated': True, 'entity': 'many2', 'pk': 2, 'lineno': 2, 'current': 2, 'path': os.path.join(dumpdir, 'many2_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 2, 'current': 2, 'path': os.path.join(dumpdir, 'many2_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'created': True, 'updated': True, 'entity': 'pdtest1', 'pk': (1, 2, 3), 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest1_dump.jsonl'), 'count': 1, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest1_dump.jsonl'), 'count': 1, 'all_count': 7},
        {'created': True, 'updated': True, 'entity': 'pdtest3', 'pk': 17, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest3_dump.jsonl'), 'count': 1, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest3_dump.jsonl'), 'count': 1, 'all_count': 7},
        {'created': True, 'updated': True, 'entity': 'pdtest2', 'pk': 1, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'), 'count': 1, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'), 'count': 1, 'all_count': 7},
        {'path': None, 'entity': None, 'pk': None, 'updated': None, 'created': None, 'count': 7, 'all_count': 7},
    ]

    for statuses in pd.load_from_files([dumpdir]):
        for status in statuses:
            assert status in load_statuses
            load_statuses.remove(status)

    assert not load_statuses
    assert not pd.get_depcache_dict()

    # update test
    PDTest3.select().first().foo_longstr = 'changed string'
    Many2.get(id=2).delete()

    load_statuses = [
        # updated=False, потому что зависимость Many2(2) ещё отсутствует в базе
        {'created': False, 'updated': False, 'entity': 'many1', 'pk': 1, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'many1_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'created': False, 'updated': False, 'entity': 'many1', 'pk': 2, 'lineno': 2, 'current': 2, 'path': os.path.join(dumpdir, 'many1_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 2, 'current': 2, 'path': os.path.join(dumpdir, 'many1_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'created': False, 'updated': False, 'entity': 'many2', 'pk': 1, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'many2_dump.jsonl'), 'count': 2, 'all_count': 7},
        # ...и создаётся только сейчас
        {'created': True, 'updated': True, 'entity': 'many2', 'pk': 2, 'lineno': 2, 'current': 2, 'path': os.path.join(dumpdir, 'many2_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 2, 'current': 2, 'path': os.path.join(dumpdir, 'many2_dump.jsonl'), 'count': 2, 'all_count': 7},
        {'created': False, 'updated': False, 'entity': 'pdtest1', 'pk': (1, 2, 3), 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest1_dump.jsonl'), 'count': 1, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest1_dump.jsonl'), 'count': 1, 'all_count': 7},
        # Ещё вот тут мы меняли атрибут
        {'created': False, 'updated': True, 'entity': 'pdtest3', 'pk': 17, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest3_dump.jsonl'), 'count': 1, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest3_dump.jsonl'), 'count': 1, 'all_count': 7},
        {'created': False, 'updated': False, 'entity': 'pdtest2', 'pk': 1, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'), 'count': 1, 'all_count': 7},
        {'entity': None, 'updated': None, 'created': None, 'pk': None, 'lineno': 1, 'current': 1, 'path': os.path.join(dumpdir, 'pdtest2_dump.jsonl.gz'), 'count': 1, 'all_count': 7},
        {'path': None, 'entity': None, 'pk': None, 'updated': None, 'created': None, 'count': 7, 'all_count': 7},
    ]

    for statuses in pd.load_from_files([dumpdir]):
        for status in statuses:
            load_statuses.remove(status)
            if status['entity'] == 'many1':
                # Проверяем, что отсутствующая зависимость Many2 положена в depcache
                deps = pd.get_depcache_dict()[(('many1', 'many2'), ('many2', 'many1'))]
                assert (2,) in deps[0].get((status['pk'],))
                assert (status['pk'],) in deps[1].get((2,))

    assert not load_statuses
    assert not pd.get_depcache_dict()

    assert PDTest1.select().count() == 1

    test1 = PDTest1.select().first()
    assert test1.get_pk() == (1, 2, 3)
    assert test1.test2.id == 1
    assert test1.test3.select().count() == 1
    assert test1.test3.select().first().id == 17

    assert PDTest2.select().count() == 1
    test2 = PDTest2.select().first()
    assert test2.get_pk() == 1
    assert test2.test1 is test1  # Pony ORM кэширует всё подряд, поэтому можно is

    assert PDTest3.select().count() == 1
    test3 = PDTest3.select().first()
    assert test3.get_pk() == 17
    assert test3.test1 is test1

    assert test3.foo_bool is True
    assert test3.foo_int == -4
    assert 0.1 + 0.2 == 0.30000000000000004
    assert test3.foo_float == 0.30000000000000004
    assert test3.foo_string == 'foo\u0000😊bar'
    assert test3.foo_longstr == 'longstr'
    assert test3.foo_datetime == datetime(2017, 6, 1, 1, 2, 3, 999987)
    assert test3.foo_uuid == uuid.UUID('8e8cdc11-0785-43a8-8203-66c148c3f57c')

    many1_1, many1_2 = Many1.select().order_by(Many1.id)[:]
    many2_1, many2_2 = Many2.select().order_by(Many2.id)[:]

    assert many1_1.many2.select().order_by(Many2.id)[:] == [many2_1, many2_2]
    assert many1_2.many2.select().order_by(Many2.id)[:] == [many2_1, many2_2]
    assert many2_1.many1.select().order_by(Many1.id)[:] == [many1_1, many1_2]
    assert many2_2.many1.select().order_by(Many1.id)[:] == [many1_1, many1_2]