Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_revision_bw_compat::test_revision_extra_header_in_metadata
Failed

TEST RESULT

Run At
Jul 21 2020, 9:55 AM
Details
swh_storage_backend_config = {'cls': 'local', 'db': 'postgresql://postgres@127.0.0.1:18082/tests', 'journal_writer': {'cls': 'memory'}, 'objstorage': {'args': {}, 'cls': 'memory'}} sample_data_model = {'authority': [MetadataAuthority(type=<MetadataAuthorityType.DEPOSIT_CLIENT: 'deposit_client'>, url='http://hal.inria....11', length=7, status='visible', data=b'424242\n', ctime=datetime.datetime(2019, 12, 1, 0, 0, tzinfo=tzlocal()))], ...} def test_revision_extra_header_in_metadata( swh_storage_backend_config, sample_data_model ): storage = get_storage(**swh_storage_backend_config) rev = sample_data_model["revision"][0] md_w_extra = dict( rev.metadata.items(), extra_headers=headers_to_db( [ ["gpgsig", b"test123"], ["mergetag", b"foo\\bar"], ["mergetag", b"\x22\xaf\x89\x80\x01\x00"], ] ), ) bw_rev = attr.evolve(rev, extra_headers=()) object.__setattr__(bw_rev, "metadata", md_w_extra) assert bw_rev.extra_headers == () assert storage.revision_add([bw_rev]) == {"revision:add": 1} # check data in the db are old format with db_transaction(storage) as (_, cur): cur.execute("SELECT metadata, extra_headers FROM revision") metadata, extra_headers = cur.fetchone() assert extra_headers == [] assert metadata == bw_rev.metadata # check the Revision build from revision_get is the original, "new style", Revision > assert [Revision.from_dict(x) for x in storage.revision_get([rev.id])] == [rev] .tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_revision_bw_compat.py:49: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_revision_bw_compat.py:49: in <listcomp> assert [Revision.from_dict(x) for x in storage.revision_get([rev.id])] == [rev] .tox/py3/lib/python3.7/site-packages/swh/core/db/common.py:97: in _meth yield from meth(self, *args, db=db, cur=cur, **kwargs) .tox/py3/lib/python3.7/site-packages/swh/storage/storage.py:615: in revision_get data = converters.db_to_revision(dict(zip(db.revision_get_cols, line))) .tox/py3/lib/python3.7/site-packages/swh/storage/converters.py:212: in db_to_revision extra_headers = db_to_git_headers(metadata.pop("extra_headers")) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ db_git_headers = [['gpgsig', 'test123'], ['mergetag', 'foo\\\\bar'], ['mergetag', '"\\xaf\\x89\\x80\x01\\x00']] def db_to_git_headers(db_git_headers): ret = [] for key, value in db_git_headers: > ret.append(tuple[key.encode("utf-8"), encode_with_unescape(value)]) E TypeError: 'type' object is not subscriptable .tox/py3/lib/python3.7/site-packages/swh/storage/converters.py:70: TypeError