Skip to content

Commit e820de7

Browse files
committed
Auto-use check_for_otdfctl fixture
1 parent 66e04e1 commit e820de7

File tree

6 files changed

+14
-28
lines changed

6 files changed

+14
-28
lines changed

tests/support_otdfctl.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
import subprocess
2+
import pytest
23

34

5+
@pytest.mark.integration
6+
@pytest.fixture(scope="session", autouse=True)
47
def check_for_otdfctl():
5-
# TODO Consider setting GRPC_ENFORCE_ALPN_ENABLED to false if issues arise
6-
# original_env = os.environ.copy()
7-
# original_env["GRPC_ENFORCE_ALPN_ENABLED"] = "false"
8+
"""
9+
Ensure that the otdfctl command is available on the system.
10+
11+
This fixture runs once per test session (for integration tests) and raises
12+
an exception if the otdfctl command is not found.
13+
"""
14+
15+
# TODO Consider setting GRPC_ENFORCE_ALPN_ENABLED to false as needed
16+
# test_env = os.environ.copy()
17+
# test_env["GRPC_ENFORCE_ALPN_ENABLED"] = "false"
818

919
# Check if otdfctl is available
1020
try:
1121
subprocess.run(
1222
["otdfctl", "--version"],
1323
capture_output=True,
1424
check=True,
15-
# env=original_env
25+
# env=test_env
1626
)
1727
except (subprocess.CalledProcessError, FileNotFoundError):
1828
raise Exception(

tests/test_cli.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import json
1111
from pathlib import Path
1212
from tests.config_pydantic import CONFIG_TDF
13-
from tests.support_otdfctl import check_for_otdfctl
1413

1514

1615
def test_cli_help():
@@ -181,8 +180,6 @@ def test_cli_encrypt_integration():
181180
"OPENTDF_PLATFORM_URL must be set in config for integration tests"
182181
)
183182

184-
check_for_otdfctl()
185-
186183
# Create temporary directory for work
187184
with tempfile.TemporaryDirectory() as temp_dir:
188185
temp_path = Path(temp_dir)

tests/test_cli_comparison.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import json
99
from pathlib import Path
1010
from tests.config_pydantic import CONFIG_TDF
11-
from tests.support_otdfctl import check_for_otdfctl
1211

1312
# Fail fast if OPENTDF_PLATFORM_URL is not set
1413
platform_url = CONFIG_TDF.OPENTDF_PLATFORM_URL
@@ -20,8 +19,6 @@
2019
def test_otdfctl_encrypt_python_decrypt(collect_server_logs):
2120
"""Integration test that uses otdfctl for encryption and the Python CLI for decryption"""
2221

23-
check_for_otdfctl()
24-
2522
# Create temporary directory for work
2623
with tempfile.TemporaryDirectory() as temp_dir:
2724
temp_path = Path(temp_dir)
@@ -197,8 +194,6 @@ def test_otdfctl_encrypt_python_decrypt(collect_server_logs):
197194
def test_otdfctl_encrypt_otdfctl_decrypt(collect_server_logs):
198195
"""Integration test that uses otdfctl for both encryption and decryption to verify roundtrip functionality"""
199196

200-
check_for_otdfctl()
201-
202197
# Create temporary directory for work
203198
with tempfile.TemporaryDirectory() as temp_dir:
204199
temp_path = Path(temp_dir)

tests/test_cli_encrypt_only.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import zipfile
1313
import os
1414
import sys
15-
from tests.support_otdfctl import check_for_otdfctl
1615

1716
original_env = os.environ.copy()
1817
original_env["GRPC_ENFORCE_ALPN_ENABLED"] = "false"
@@ -314,7 +313,6 @@ def _run_otdfctl_inspect(
314313
@pytest.mark.integration
315314
def test_otdfctl_encrypt(collect_server_logs):
316315
"""Integration test that uses otdfctl for encryption only and verifies the TDF can be inspected"""
317-
check_for_otdfctl()
318316

319317
# Create temporary directory for work
320318
with tempfile.TemporaryDirectory() as temp_dir:
@@ -373,7 +371,6 @@ def test_otdfctl_encrypt(collect_server_logs):
373371
@pytest.mark.integration
374372
def test_python_encrypt(collect_server_logs):
375373
"""Integration test that uses Python CLI for encryption only and verifies the TDF can be inspected"""
376-
check_for_otdfctl()
377374

378375
# Create temporary directory for work
379376
with tempfile.TemporaryDirectory() as temp_dir:

tests/test_cli_roundtrip.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from tests.config_pydantic import CONFIG_TDF
1212
import os
1313

14-
from tests.support_otdfctl import check_for_otdfctl
1514

1615
original_env = os.environ.copy()
1716
original_env["GRPC_ENFORCE_ALPN_ENABLED"] = "false"
@@ -28,8 +27,6 @@ def test_cli_decrypt_otdfctl_tdf():
2827
Test that the Python CLI can successfully decrypt TDF files created by otdfctl.
2928
"""
3029

31-
check_for_otdfctl()
32-
3330
# Create temporary directory for work
3431
with tempfile.TemporaryDirectory() as temp_dir:
3532
temp_path = Path(temp_dir)
@@ -134,7 +131,6 @@ def test_otdfctl_decrypt_comparison(collect_server_logs):
134131
"""
135132
Test comparative decryption between otdfctl and Python CLI on the same TDF.
136133
"""
137-
check_for_otdfctl()
138134

139135
# Create temporary directory for work
140136
with tempfile.TemporaryDirectory() as temp_dir:
@@ -305,8 +301,6 @@ def test_otdfctl_encrypt_decrypt_roundtrip(collect_server_logs):
305301
Test complete encrypt-decrypt roundtrip using otdfctl to verify functionality.
306302
"""
307303

308-
check_for_otdfctl()
309-
310304
# Create temporary directory for work
311305
with tempfile.TemporaryDirectory() as temp_dir:
312306
temp_path = Path(temp_dir)

tests/test_tdf_reader_integration.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
TDFReader,
1414
)
1515
from tests.config_pydantic import CONFIG_TDF
16-
from tests.support_otdfctl import check_for_otdfctl
1716

1817
# Fail fast if OPENTDF_PLATFORM_URL is not set
1918
platform_url = CONFIG_TDF.OPENTDF_PLATFORM_URL
@@ -28,8 +27,6 @@ class TestTDFReaderIntegration:
2827
def test_read_otdfctl_created_tdf_structure(self):
2928
"""Test that TDFReader can parse the structure of files created by otdfctl."""
3029

31-
check_for_otdfctl()
32-
3330
# Create temporary directory for work
3431
with tempfile.TemporaryDirectory() as temp_dir:
3532
temp_path = Path(temp_dir)
@@ -125,8 +122,6 @@ def test_read_otdfctl_created_tdf_structure(self):
125122
def test_read_otdfctl_tdf_with_attributes(self):
126123
"""Test reading TDF files created by otdfctl with data attributes."""
127124

128-
check_for_otdfctl()
129-
130125
# Create temporary directory for work
131126
with tempfile.TemporaryDirectory() as temp_dir:
132127
temp_path = Path(temp_dir)
@@ -215,8 +210,6 @@ def test_read_otdfctl_tdf_with_attributes(self):
215210
def test_read_multiple_otdfctl_files(self):
216211
"""Test reading multiple TDF files of different types created by otdfctl."""
217212

218-
check_for_otdfctl()
219-
220213
# Create temporary directory for work
221214
with tempfile.TemporaryDirectory() as temp_dir:
222215
temp_path = Path(temp_dir)

0 commit comments

Comments
 (0)