From 710fb4249e4b071aa77324da8a7f89ba0a0bad5c Mon Sep 17 00:00:00 2001 From: Valentin Lorentz <vlorentz@softwareheritage.org> Date: Tue, 23 Feb 2021 11:32:01 +0100 Subject: [PATCH] Add test checking SWHID_QUALIFIERS matches the attributes of QualifiedSWHID. --- swh/model/tests/test_identifiers.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/swh/model/tests/test_identifiers.py b/swh/model/tests/test_identifiers.py index 77e6e4dd..6d1a7540 100644 --- a/swh/model/tests/test_identifiers.py +++ b/swh/model/tests/test_identifiers.py @@ -9,6 +9,7 @@ import itertools from typing import Dict import unittest +import attr import pytest from swh.model import hashutil, identifiers @@ -21,6 +22,7 @@ from swh.model.identifiers import ( REVISION, SNAPSHOT, SWHID, + SWHID_QUALIFIERS, CoreSWHID, ExtendedObjectType, ExtendedSWHID, @@ -1534,6 +1536,19 @@ def test_QualifiedSWHID_parse_qualifiers(string, parsed): assert str(parsed) == string +def test_QualifiedSWHID_attributes(): + """Checks the set of QualifiedSWHID attributes match the SWHID_QUALIFIERS + constant.""" + + assert set(attr.fields_dict(QualifiedSWHID)) == { + "namespace", + "scheme_version", + "object_type", + "object_id", + *SWHID_QUALIFIERS, + } + + @pytest.mark.parametrize( "ns,version,type,id", [ -- GitLab