Changeset View
Changeset View
Standalone View
Standalone View
swh/clearlydefined/tests/test_mapping.py
- This file was added.
from swh.clearlydefined.mapping_utils import map_sha1_with_swhid | |||||
import psycopg2 | |||||
def test_mapping(swh_storage_backend_config): | |||||
dsn = swh_storage_backend_config["db"] | |||||
read_connection = psycopg2.connect(dsn=dsn) | |||||
cur = read_connection.cursor() | |||||
sha1_byte = "\\xa6628c8a4fbc08c29b8472e2222975e5b9918131" | |||||
sha1_git_byte = "\\xe103b11cbfecbc116dacbb1f9ab2a02176092a32" | |||||
sha256_byte = "\\x6ac599151a7aaa8ca5d38dc5bb61b49193a3cadc1ed33de5a57e4d1ecc53c846" | |||||
blake2s256_byte = "\\xc509b320abede3580bb1de75a0efa09ba7416db9c8de845a4e1b4317c0b8a8d9" | |||||
vlorentz: one last thing: this connection is not used for reading | |||||
length = 717 | |||||
cur.execute( | |||||
"INSERT INTO content (sha1, sha1_git, sha256, blake2s256, length) VALUES (%s,%s,%s,%s,%s);", | |||||
(sha1_byte, sha1_git_byte, sha256_byte, blake2s256_byte, length), | |||||
) | |||||
read_connection.commit() | |||||
sha1 = "a6628c8a4fbc08c29b8472e2222975e5b9918131" | |||||
assert "swh:1:cnt:e103b11cbfecbc116dacbb1f9ab2a02176092a32" == map_sha1_with_swhid( | |||||
sha1=sha1, dsn=dsn | |||||
) | |||||
Not Done Inline ActionsI was about to ask you to use hash_to_bytes here as well, but on second thoughts, it's more readable the way you did it, so let's keep it that way :) vlorentz: I was about to ask you to use `hash_to_bytes` here as well, but on second thoughts, it's more… | |||||
Not Done Inline ActionsThis test doesn't check anything:
Could you update the test to fix that? vlorentz: This test doesn't check anything:
1. if the function returns `None` like it should, then it… | |||||
Not Done Inline Actionssame issue here vlorentz: same issue here |
one last thing: this connection is not used for reading