Skip to content

Commit

Permalink
Merge pull request #118 from mitre-attack/directory-agnostic-testing
Browse files Browse the repository at this point in the history
Make pytest pass tests when run in project directory root
  • Loading branch information
jondricek authored Aug 9, 2023
2 parents 0f15867 + 7b7ea88 commit b1e5252
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions tests/test_collections.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os

from resources.testing_data import collection, index

Expand All @@ -21,10 +22,14 @@ def test_collection_to_index():

def test_stix_to_collection():
"""Test converting stix bundle file to a collection"""
with open("resources/ics-bundle.json", "r") as fio:
dir = os.path.dirname(__file__)
ics_bundle_collection = os.path.join(dir, "resources", "ics-bundle.json")
enterprise_bundle_collection = os.path.join(dir, "resources", "enterprise-bundle.json")

with open(ics_bundle_collection, "r") as fio:
v20 = json.load(fio)

with open("resources/enterprise-bundle.json", "r") as fio:
with open(enterprise_bundle_collection, "r") as fio:
v21 = json.load(fio)

STIXToCollection.stix_to_collection(v20, name="v20_test", version="9.0", description="testing")
Expand Down
4 changes: 3 additions & 1 deletion tests/test_layers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
from pathlib import Path

import pytest
Expand Down Expand Up @@ -36,7 +37,8 @@ def test_depreciated_tactics_export(tmp_path: Path, memstore_enterprise_latest:
def test_colormap_export(tmp_path: Path, memstore_enterprise_latest: MemoryStore):
"""Test exporting a layer with a gradiant of scores"""
lay = Layer()
lay.from_file("resources/heatmap_example.json")
dir = os.path.dirname(__file__)
lay.from_file(os.path.join(dir, "resources", "heatmap_example.json"))
xlsx_output = tmp_path / "layer.xlsx"
svg_output = tmp_path / "layer.svg"

Expand Down

0 comments on commit b1e5252

Please sign in to comment.