Skip to content

Commit 054bbe2

Browse files
committed
- Fixing file paths to work from the project root instead of the tests folder
1 parent b182b41 commit 054bbe2

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

tests/test_pm.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
PolicySpecification)
2929
from vcert.policy.pm_cloud import CA_TYPE_DIGICERT, CA_TYPE_ENTRUST
3030

31-
POLICY_SPEC_JSON = 'resources/policy_specification.json'
32-
POLICY_SPEC_YAML = 'resources/policy_specification.yaml'
31+
# This values are loaded from the project root which is vcert-python, not tests folder
32+
POLICY_SPEC_JSON = './tests/resources/policy_specification.json'
33+
POLICY_SPEC_YAML = './tests/resources/policy_specification.yaml'
3334
CA_TYPE_TPP = 'TPP'
3435

3536
log = logger.get_child("test-pm")
@@ -38,8 +39,8 @@
3839
class TestParsers(unittest.TestCase):
3940
def __init__(self, *args, **kwargs):
4041
super(TestParsers, self).__init__(*args, **kwargs)
41-
self.json_file = _resolve_resources_path(POLICY_SPEC_JSON)
42-
self.yaml_file = _resolve_resources_path(POLICY_SPEC_YAML)
42+
self.json_file = POLICY_SPEC_JSON
43+
self.yaml_file = POLICY_SPEC_YAML
4344

4445
def test_json_parsing(self):
4546
ps = json_parser.parse_file(self.json_file)
@@ -86,8 +87,8 @@ def __init__(self, *args, **kwargs):
8687
self.tpp_conn = TPPTokenConnection(url=TPP_TOKEN_URL, http_request_kwargs={'verify': "/tmp/chain.pem"})
8788
auth = Authentication(user=TPP_USER, password=TPP_PASSWORD, scope=SCOPE_PM)
8889
self.tpp_conn.get_access_token(auth)
89-
self.json_file = _resolve_resources_path(POLICY_SPEC_JSON)
90-
self.yaml_file = _resolve_resources_path(POLICY_SPEC_YAML)
90+
self.json_file = POLICY_SPEC_JSON
91+
self.yaml_file = POLICY_SPEC_YAML
9192
super(TestTPPPolicyManagement, self).__init__(*args, **kwargs)
9293

9394
def test_create_policy_from_json(self):
@@ -124,8 +125,8 @@ def _create_policy_tpp(self, policy_spec=None, policy=None, defaults=None):
124125
class TestCloudPolicyManagement(unittest.TestCase):
125126
def __init__(self, *args, **kwargs):
126127
self.cloud_conn = CloudConnection(token=CLOUD_APIKEY, url=CLOUD_URL)
127-
self.json_file = _resolve_resources_path(POLICY_SPEC_JSON)
128-
self.yaml_file = _resolve_resources_path(POLICY_SPEC_YAML)
128+
self.json_file = POLICY_SPEC_JSON
129+
self.yaml_file = POLICY_SPEC_YAML
129130
super(TestCloudPolicyManagement, self).__init__(*args, **kwargs)
130131

131132
def test_create_policy_from_json(self):
@@ -262,10 +263,12 @@ def _get_tpp_policy_name():
262263
time = timestamp()
263264
return f"{_get_app_name().format(time)}"
264265

265-
266-
def _resolve_resources_path(path):
267-
resources_dir = os.path.dirname(__file__)
268-
log.debug(f"Testing root folder: [{resources_dir}]")
269-
resolved_path = f"./{path}" if resources_dir.endswith('tests') else f"./tests/{path}"
270-
log.debug(f"resolved path: [{resolved_path}]")
271-
return resolved_path
266+
# def _resolve_resources_path(path):
267+
# resources_dir = os.path.dirname(__file__)
268+
# log.debug(f"Testing root folder: [{resources_dir}]")
269+
# if resources_dir.endswith('tests'):
270+
# resolved_path = f"./{path}"
271+
# else:
272+
# resolved_path = f"./tests/{path}"
273+
# log.debug(f"resolved path: [{resolved_path}]")
274+
# return resolved_path

0 commit comments

Comments
 (0)