Skip to content

Commit

Permalink
Merge pull request #307 from STIXProject/datetime-format-test
Browse files Browse the repository at this point in the history
Add test for datetime format
  • Loading branch information
gtback committed Oct 21, 2016
2 parents 7f05e1a + ddf0ba7 commit 97a0cea
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion stix/test/indicator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# See LICENSE.txt for complete terms.

import unittest
from datetime import datetime
from mixbox.vendor.six import text_type

from stix.core import STIXPackage
from stix.indicator import Indicator, RelatedCampaignRefs
from stix.indicator import Indicator, RelatedCampaignRefs, ValidTime

from stix.test import EntityTestCase, assert_warnings
from stix.test.common import related_test
Expand Down Expand Up @@ -446,6 +448,15 @@ def test_deprecated_related_packages(self):
i.related_packages.append(STIXPackage())
self.assertEqual(len(i.related_packages), 1)

def test_datetime_format(self):
indicator = Indicator(title="title")
valid_time = ValidTime(start_time=datetime.strptime("2010-03-05",
"%Y-%m-%d"))
indicator.add_valid_time_position(valid_time)

ixml = indicator.to_xml()
self.assertTrue("2010-03-05T" in text_type(ixml))


class RelatedCampaignReferencesTests(unittest.TestCase, EntityTestCase):
klass = RelatedCampaignRefs
Expand Down

0 comments on commit 97a0cea

Please sign in to comment.