Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_model.py
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
def test_content_get_hash(): | def test_content_get_hash(): | ||||
hashes = dict( | hashes = dict( | ||||
sha1=b'foo', sha1_git=b'bar', sha256=b'baz', blake2s256=b'qux') | sha1=b'foo', sha1_git=b'bar', sha256=b'baz', blake2s256=b'qux') | ||||
c = Content(length=42, status='visible', **hashes) | c = Content(length=42, status='visible', **hashes) | ||||
for (hash_name, hash_) in hashes.items(): | for (hash_name, hash_) in hashes.items(): | ||||
assert c.get_hash(hash_name) == hash_ | assert c.get_hash(hash_name) == hash_ | ||||
def test_content_hashes(): | |||||
hashes = dict( | |||||
sha1=b'foo', sha1_git=b'bar', sha256=b'baz', blake2s256=b'qux') | |||||
c = Content(length=42, status='visible', **hashes) | |||||
assert c.hashes() == hashes | |||||
def test_directory_model_id_computation(): | def test_directory_model_id_computation(): | ||||
dir_dict = dict(directory_example) | dir_dict = dict(directory_example) | ||||
del dir_dict['id'] | del dir_dict['id'] | ||||
dir_id = hash_to_bytes(directory_identifier(dir_dict)) | dir_id = hash_to_bytes(directory_identifier(dir_dict)) | ||||
for dir_model in [Directory(**dir_dict), Directory.from_dict(dir_dict)]: | for dir_model in [Directory(**dir_dict), Directory.from_dict(dir_dict)]: | ||||
assert dir_model.id == dir_id | assert dir_model.id == dir_id | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |