Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_model.py
Show All 15 Lines | |||||
import swh.model.hypothesis_strategies as strategies | import swh.model.hypothesis_strategies as strategies | ||||
from swh.model.identifiers import ( | from swh.model.identifiers import ( | ||||
CoreSWHID, | CoreSWHID, | ||||
ExtendedSWHID, | ExtendedSWHID, | ||||
ObjectType, | ObjectType, | ||||
content_identifier, | content_identifier, | ||||
directory_identifier, | directory_identifier, | ||||
origin_identifier, | origin_identifier, | ||||
raw_extrinsic_metadata_identifier, | |||||
release_identifier, | release_identifier, | ||||
revision_identifier, | revision_identifier, | ||||
snapshot_identifier, | snapshot_identifier, | ||||
) | ) | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
BaseModel, | BaseModel, | ||||
Content, | Content, | ||||
Directory, | Directory, | ||||
▲ Show 20 Lines • Show All 765 Lines • ▼ Show 20 Lines | |||||
def test_origin_model_id_computation(): | def test_origin_model_id_computation(): | ||||
ori_dict = origin_example.copy() | ori_dict = origin_example.copy() | ||||
ori_id_str = origin_identifier(ori_dict) | ori_id_str = origin_identifier(ori_dict) | ||||
ori_model = Origin.from_dict(ori_dict) | ori_model = Origin.from_dict(ori_dict) | ||||
assert str(ori_model.swhid()) == "swh:1:ori:" + ori_id_str | assert str(ori_model.swhid()) == "swh:1:ori:" + ori_id_str | ||||
def test_raw_extrinsic_metadata_model_id_computation(): | |||||
emd_dict = metadata_example.copy() | |||||
emd_id_str = raw_extrinsic_metadata_identifier(emd_dict) | |||||
emd_model = RawExtrinsicMetadata.from_dict(emd_dict) | |||||
assert str(emd_model.swhid()) == "swh:1:emd:" + emd_id_str | |||||
@given(strategies.objects(split_content=True)) | @given(strategies.objects(split_content=True)) | ||||
def test_object_type(objtype_and_obj): | def test_object_type(objtype_and_obj): | ||||
obj_type, obj = objtype_and_obj | obj_type, obj = objtype_and_obj | ||||
assert obj_type == obj.object_type | assert obj_type == obj.object_type | ||||
def test_object_type_is_final(): | def test_object_type_is_final(): | ||||
object_types = set() | object_types = set() | ||||
▲ Show 20 Lines • Show All 321 Lines • Show Last 20 Lines |