Add test for _register_type()

stix2.0
Emmanuelle Vargas-Gonzalez 2017-10-29 00:09:13 -04:00
parent b9d25a8375
commit a514c5a3df
1 changed files with 10 additions and 0 deletions

View File

@ -483,3 +483,13 @@ def test_parse_observable_with_unregistered_custom_extension():
with pytest.raises(ValueError) as excinfo:
stix2.parse_observable(input_str)
assert "Can't parse Unknown extension type" in str(excinfo.value)
def test_register_custom_object():
# Not the way to register custom object.
class CustomObject2(object):
_type = 'awesome-object'
stix2._register_type(CustomObject2)
# Note that we will always check against newest OBJ_MAP.
assert (CustomObject2._type, CustomObject2) in stix2.OBJ_MAP.items()