Add a unit test for the first/last_seen value co-constraint

on ThreatActor.
master
Michael Chisholm 2019-07-25 16:57:15 -04:00
parent 8362d80206
commit 423487d65a
1 changed files with 24 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import pytest
import pytz import pytz
import stix2 import stix2
import stix2.v21
from .constants import IDENTITY_ID, THREAT_ACTOR_ID from .constants import IDENTITY_ID, THREAT_ACTOR_ID
@ -67,4 +68,27 @@ def test_parse_threat_actor(data):
assert actor.name == "Evil Org" assert actor.name == "Evil Org"
assert actor.threat_actor_types == ["crime-syndicate"] assert actor.threat_actor_types == ["crime-syndicate"]
def test_seen_ordering_constraint():
"""
Test first_seen/last_seen value co-constraint.
"""
with pytest.raises(ValueError):
stix2.v21.ThreatActor(
name="Bad Person",
threat_actor_types=["bad person", "evil person"],
first_seen="2010-04-21T09:31:11Z",
last_seen="2009-02-06T03:39:31Z",
)
# equal timestamps is okay.
stix2.v21.ThreatActor(
name="Bad Person",
threat_actor_types=["bad person", "evil person"],
first_seen="2010-04-21T09:31:11Z",
last_seen="2010-04-21T09:31:11Z",
)
# TODO: Add other examples # TODO: Add other examples