Add a check in ReferenceProperty constructor for an impossible
to satisfy type constraint: empty whitelist. It would be silly for anyone to do that, but I should check just in case I guess.pull/1/head
parent
c7dd58ed89
commit
03c265c3a3
|
@ -511,6 +511,9 @@ class ReferenceProperty(Property):
|
|||
elif invalid_types and not isinstance(invalid_types, list):
|
||||
invalid_types = [invalid_types]
|
||||
|
||||
if valid_types is not None and len(valid_types) == 0:
|
||||
raise ValueError("Impossible type constraint: empty whitelist")
|
||||
|
||||
self.types = set(valid_types or invalid_types)
|
||||
self.auth_type = self._WHITELIST if valid_types else self._BLACKLIST
|
||||
|
||||
|
|
|
@ -229,6 +229,11 @@ def test_reference_property_hybrid_constraint_type():
|
|||
ReferenceProperty(invalid_types=["a", "SCO"], spec_version="2.0")
|
||||
|
||||
|
||||
def test_reference_property_impossible_constraint():
|
||||
with pytest.raises(ValueError):
|
||||
ReferenceProperty(valid_types=[], spec_version="2.0")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"d", [
|
||||
{'description': 'something'},
|
||||
|
|
|
@ -250,6 +250,11 @@ def test_reference_property_hybrid_constraint_type():
|
|||
ReferenceProperty(invalid_types=["a", "SCO"], spec_version="2.1")
|
||||
|
||||
|
||||
def test_reference_property_impossible_constraint():
|
||||
with pytest.raises(ValueError):
|
||||
ReferenceProperty(valid_types=[], spec_version="2.1")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"d", [
|
||||
{'description': 'something'},
|
||||
|
|
Loading…
Reference in New Issue