Add trailing commas for the pre-commit hook......

master
Michael Chisholm 2020-02-07 18:58:45 -05:00
parent 19707677c9
commit bf83ca62b3
2 changed files with 200 additions and 198 deletions

View File

@ -86,7 +86,7 @@ def _detect_spec_version(stix_dict):
"v21",
max(
_detect_spec_version(obj) for obj in stix_dict["objects"]
)
),
)
elif obj_type in STIX2_OBJ_MAPS["v21"]["observables"]:
# Non-bundle object with an ID and without spec_version. Could be a

View File

@ -5,7 +5,8 @@ import pytest
from stix2.core import _detect_spec_version
@pytest.mark.parametrize("obj_dict, expected_ver", [
@pytest.mark.parametrize(
"obj_dict, expected_ver", [
# STIX 2.0 examples
(
{
@ -14,7 +15,7 @@ from stix2.core import _detect_spec_version
"created": "1972-05-21T05:33:09.000Z",
"modified": "1973-05-28T02:10:54.000Z",
"name": "alice",
"identity_class": "individual"
"identity_class": "individual",
},
"v20"
),
@ -26,14 +27,14 @@ from stix2.core import _detect_spec_version
"modified": "2000-02-16T15:33:15.000Z",
"source_ref": "attack-pattern--9391504a-ef29-4a41-a257-5634d9edc391",
"target_ref": "identity--ba18dde2-56d3-4a34-aa0b-fc56f5be568f",
"relationship_type": "targets"
"relationship_type": "targets",
},
"v20"
),
(
{
"type": "file",
"name": "notes.txt"
"name": "notes.txt",
},
"v20"
),
@ -44,8 +45,8 @@ from stix2.core import _detect_spec_version
"created": "1998-03-27T19:44:53.000Z",
"definition_type": "statement",
"definition": {
"statement": "Copyright (c) ACME Corp."
}
"statement": "Copyright (c) ACME Corp.",
},
},
"v20"
),
@ -61,7 +62,7 @@ from stix2.core import _detect_spec_version
"created": "1972-05-21T05:33:09.000Z",
"modified": "1973-05-28T02:10:54.000Z",
"name": "alice",
"identity_class": "individual"
"identity_class": "individual",
},
{
"type": "marking-definition",
@ -69,10 +70,10 @@ from stix2.core import _detect_spec_version
"created": "1998-03-27T19:44:53.000Z",
"definition_type": "statement",
"definition": {
"statement": "Copyright (c) ACME Corp."
}
}
]
"statement": "Copyright (c) ACME Corp.",
},
},
],
},
"v20"
),
@ -84,7 +85,7 @@ from stix2.core import _detect_spec_version
"spec_version": "2.1",
"created": "1995-07-24T04:07:48.000Z",
"modified": "2001-07-01T09:33:17.000Z",
"name": "alice"
"name": "alice",
},
"v21"
),
@ -97,7 +98,7 @@ from stix2.core import _detect_spec_version
"modified": "1983-04-25T20:56:00.000Z",
"source_ref": "attack-pattern--9391504a-ef29-4a41-a257-5634d9edc391",
"target_ref": "identity--ba18dde2-56d3-4a34-aa0b-fc56f5be568f",
"relationship_type": "targets"
"relationship_type": "targets",
},
"v21"
),
@ -106,7 +107,7 @@ from stix2.core import _detect_spec_version
"type": "file",
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
"spec_version": "2.1",
"name": "notes.txt"
"name": "notes.txt",
},
"v21"
),
@ -114,7 +115,7 @@ from stix2.core import _detect_spec_version
{
"type": "file",
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
"name": "notes.txt"
"name": "notes.txt",
},
"v21"
),
@ -127,8 +128,8 @@ from stix2.core import _detect_spec_version
"definition_type": "tlp",
"name": "TLP:GREEN",
"definition": {
"tlp": "green"
}
"tlp": "green",
},
},
"v21"
),
@ -143,14 +144,14 @@ from stix2.core import _detect_spec_version
"spec_version": "2.1",
"created": "1995-07-24T04:07:48.000Z",
"modified": "2001-07-01T09:33:17.000Z",
"name": "alice"
"name": "alice",
},
{
"type": "file",
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
"name": "notes.txt"
"name": "notes.txt",
},
]
],
},
"v21"
),
@ -166,7 +167,7 @@ from stix2.core import _detect_spec_version
"created": "1972-05-21T05:33:09.000Z",
"modified": "1973-05-28T02:10:54.000Z",
"name": "alice",
"identity_class": "individual"
"identity_class": "individual",
},
{
"type": "relationship",
@ -175,9 +176,9 @@ from stix2.core import _detect_spec_version
"modified": "2000-02-16T15:33:15.000Z",
"source_ref": "attack-pattern--9391504a-ef29-4a41-a257-5634d9edc391",
"target_ref": "identity--ba18dde2-56d3-4a34-aa0b-fc56f5be568f",
"relationship_type": "targets"
"relationship_type": "targets",
},
]
],
},
"v21"
),
@ -192,18 +193,19 @@ from stix2.core import _detect_spec_version
"created": "1972-05-21T05:33:09.000Z",
"modified": "1973-05-28T02:10:54.000Z",
"name": "alice",
"identity_class": "individual"
"identity_class": "individual",
},
{
"type": "file",
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
"name": "notes.txt"
"name": "notes.txt",
},
]
],
},
"v21"
)
])
),
],
)
def test_spec_version_detect(obj_dict, expected_ver):
detected_ver = _detect_spec_version(obj_dict)