Add test for coverage
Tests creating a property with both required and default.pull/1/head
parent
3397805367
commit
53dbc5835e
|
@ -4,7 +4,7 @@ import pytest
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
import stix2
|
import stix2
|
||||||
from stix2.exceptions import ExtraPropertiesError
|
from stix2.exceptions import ExtraPropertiesError, STIXError
|
||||||
from stix2.properties import (
|
from stix2.properties import (
|
||||||
BinaryProperty, BooleanProperty, EmbeddedObjectProperty, EnumProperty,
|
BinaryProperty, BooleanProperty, EmbeddedObjectProperty, EnumProperty,
|
||||||
FloatProperty, HexProperty, IntegerProperty, ListProperty, Property,
|
FloatProperty, HexProperty, IntegerProperty, ListProperty, Property,
|
||||||
|
@ -47,7 +47,7 @@ def test_property_default():
|
||||||
assert p.default() == 77
|
assert p.default() == 77
|
||||||
|
|
||||||
|
|
||||||
def test_fixed_property():
|
def test_property_fixed():
|
||||||
p = Property(fixed="2.0")
|
p = Property(fixed="2.0")
|
||||||
|
|
||||||
assert p.clean("2.0")
|
assert p.clean("2.0")
|
||||||
|
@ -60,6 +60,11 @@ def test_fixed_property():
|
||||||
assert p.clean(p.default())
|
assert p.clean(p.default())
|
||||||
|
|
||||||
|
|
||||||
|
def test_property_fixed_and_required():
|
||||||
|
with pytest.raises(STIXError):
|
||||||
|
Property(default=lambda: 3, required=True)
|
||||||
|
|
||||||
|
|
||||||
def test_list_property():
|
def test_list_property():
|
||||||
p = ListProperty(StringProperty)
|
p = ListProperty(StringProperty)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue