Skip to content

Commit 9642420

Browse files
committed
chore: lint
1 parent ca17791 commit 9642420

File tree

7 files changed

+193
-131
lines changed

7 files changed

+193
-131
lines changed

scripts/run_all_tests.py

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,29 @@
2121
def run_test_script(script_name, env):
2222
"""Run a single test script with the specified environment."""
2323
script_path = os.path.join(os.path.dirname(__file__), script_name)
24-
24+
2525
print(f"\n{'='*80}")
2626
print(f"Running {script_name}")
2727
print(f"{'='*80}")
28-
28+
2929
try:
3030
# Run the script with the same environment argument
31-
result = subprocess.run([
32-
sys.executable, script_path, '--env', env
33-
], capture_output=False, text=True, check=False)
34-
31+
result = subprocess.run(
32+
[sys.executable, script_path, "--env", env],
33+
capture_output=False,
34+
text=True,
35+
check=False,
36+
)
37+
3538
if result.returncode == 0:
3639
print(f"✅ {script_name} passed")
3740
return True
3841
else:
39-
print(f"❌ {script_name} failed with exit code {result.returncode}")
42+
print(
43+
f"❌ {script_name} failed with exit code {result.returncode}"
44+
)
4045
return False
41-
46+
4247
except Exception as e:
4348
print(f"❌ Error running {script_name}: {e}")
4449
return False
@@ -47,50 +52,53 @@ def run_test_script(script_name, env):
4752
def main():
4853
"""Main function to run all integration tests."""
4954
args = parse_test_args()
50-
55+
5156
print("🚀 Running All Integration Tests")
5257
print(f"Environment: {'Production' if args.env == 'prod' else 'Local'}")
53-
54-
target_url = ('https://metadata-portal.allenneuraldynamics-test.org'
55-
if args.env == 'prod' else 'http://localhost:5006')
58+
59+
target_url = (
60+
"https://metadata-portal.allenneuraldynamics-test.org"
61+
if args.env == "prod"
62+
else "http://localhost:5006"
63+
)
5664
print(f"Target URL: {target_url}")
57-
65+
5866
# List of test scripts to run
5967
test_scripts = [
60-
'test_200.py',
61-
'test_400.py',
62-
'test_individual_fields.py',
63-
'test_files_endpoint.py',
64-
'test_gather_integration.py'
68+
"test_200.py",
69+
"test_400.py",
70+
"test_individual_fields.py",
71+
"test_files_endpoint.py",
72+
"test_gather_integration.py",
6573
]
66-
74+
6775
results = []
68-
76+
6977
# Run each test script
7078
for script in test_scripts:
7179
success = run_test_script(script, args.env)
7280
results.append((script, success))
73-
81+
7482
# Print summary
7583
print(f"\n{'='*80}")
7684
print("TEST SUMMARY")
7785
print(f"{'='*80}")
78-
86+
7987
passed = 0
8088
failed = 0
81-
89+
8290
for script, success in results:
8391
status = "✅ PASSED" if success else "❌ FAILED"
8492
print(f"{script:<30} {status}")
8593
if success:
8694
passed += 1
8795
else:
8896
failed += 1
89-
97+
9098
print(f"\nTotal: {len(results)} tests")
9199
print(f"Passed: {passed}")
92100
print(f"Failed: {failed}")
93-
101+
94102
if failed == 0:
95103
print("\n🎉 All tests passed!")
96104
sys.exit(0)

scripts/test_200.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66
# Parse command line arguments
77
args = parse_test_args()
8-
base_url = 'https://metadata-portal.allenneuraldynamics-test.org' if args.env == 'prod' else 'http://localhost:5006'
8+
base_url = (
9+
"https://metadata-portal.allenneuraldynamics-test.org"
10+
if args.env == "prod"
11+
else "http://localhost:5006"
12+
)
913

1014
print(f"Testing against: {base_url}")
1115
print("=" * 50)
@@ -19,9 +23,7 @@
1923
metadata = json.load(f)
2024

2125
# Send the valid metadata to the validation endpoint
22-
response = requests.post(
23-
f"{base_url}/validate/metadata", json=metadata
24-
)
26+
response = requests.post(f"{base_url}/validate/metadata", json=metadata)
2527

2628
print(f"Status: {response.status_code}")
2729
print(f"Response: {response.text}")

scripts/test_400.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
# Parse command line arguments
55
args = parse_test_args()
6-
base_url = 'https://metadata-portal.allenneuraldynamics-test.org' if args.env == 'prod' else 'http://localhost:5006'
6+
base_url = (
7+
"https://metadata-portal.allenneuraldynamics-test.org"
8+
if args.env == "prod"
9+
else "http://localhost:5006"
10+
)
711

812
print(f"Testing against: {base_url}")
913
print("=" * 50)

scripts/test_config.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
"""Configuration module for integration tests."""
2+
23
import argparse
34

45

56
def get_base_url():
67
"""Get the base URL for the tests based on command line arguments."""
7-
parser = argparse.ArgumentParser(description='Run integration tests')
8+
parser = argparse.ArgumentParser(description="Run integration tests")
89
parser.add_argument(
9-
'--env',
10-
choices=['local', 'prod'],
11-
default='local',
12-
help='Environment to test against (local or prod)'
10+
"--env",
11+
choices=["local", "prod"],
12+
default="local",
13+
help="Environment to test against (local or prod)",
1314
)
1415

1516
# Parse known args to avoid conflicts when imported from other scripts
1617
args, _ = parser.parse_known_args()
1718

18-
if args.env == 'prod':
19-
return 'https://metadata-portal.allenneuraldynamics-test.org'
19+
if args.env == "prod":
20+
return "https://metadata-portal.allenneuraldynamics-test.org"
2021
else:
21-
return 'http://localhost:5006'
22+
return "http://localhost:5006"
2223

2324

2425
def parse_test_args():
2526
"""Parse command line arguments for test scripts."""
26-
parser = argparse.ArgumentParser(description='Run integration tests')
27+
parser = argparse.ArgumentParser(description="Run integration tests")
2728
parser.add_argument(
28-
'--env',
29-
choices=['local', 'prod'],
30-
default='local',
31-
help='Environment to test against (local or prod)'
29+
"--env",
30+
choices=["local", "prod"],
31+
default="local",
32+
help="Environment to test against (local or prod)",
3233
)
3334

3435
return parser.parse_args()

scripts/test_files_endpoint.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313

1414
# Parse command line arguments
1515
args = parse_test_args()
16-
base_url = 'https://metadata-portal.allenneuraldynamics-test.org' if args.env == 'prod' else 'http://localhost:5006'
16+
base_url = (
17+
"https://metadata-portal.allenneuraldynamics-test.org"
18+
if args.env == "prod"
19+
else "http://localhost:5006"
20+
)
1721

1822
print(f"Testing /validate/files endpoint against: {base_url}")
1923
print("=" * 50)
@@ -30,14 +34,14 @@
3034

3135
# Define the core fields that should be kept
3236
core_fields = [
33-
'subject',
34-
'data_description',
35-
'instrument',
36-
'quality_control',
37-
'processing',
38-
'procedures',
39-
'acquisition',
40-
'model'
37+
"subject",
38+
"data_description",
39+
"instrument",
40+
"quality_control",
41+
"processing",
42+
"procedures",
43+
"acquisition",
44+
"model",
4145
]
4246

4347
# Create a new metadata object with only core fields
@@ -46,11 +50,16 @@
4650
if field in metadata:
4751
files_metadata[field] = metadata[field]
4852

49-
print(f"Files metadata has {len(files_metadata)} top-level fields: {list(files_metadata.keys())}")
53+
print(
54+
f"Files metadata has {len(files_metadata)} top-level fields: {list(files_metadata.keys())}"
55+
)
5056

5157
# Verify that data_description.name exists
52-
if 'data_description' in files_metadata and 'name' in files_metadata['data_description']:
53-
expected_name = files_metadata['data_description']['name']
58+
if (
59+
"data_description" in files_metadata
60+
and "name" in files_metadata["data_description"]
61+
):
62+
expected_name = files_metadata["data_description"]["name"]
5463
print(f"Expected name from data_description.name: {expected_name}")
5564
else:
5665
print("ERROR: data_description.name field is missing!")
@@ -59,9 +68,7 @@
5968
# Send the files metadata to the validation endpoint
6069
try:
6170
response = requests.post(
62-
f"{base_url}/validate/files",
63-
json=files_metadata,
64-
timeout=30
71+
f"{base_url}/validate/files", json=files_metadata, timeout=30
6572
)
6673

6774
print(f"\nStatus: {response.status_code}")
@@ -79,7 +86,9 @@
7986
print("\n✅ Test PASSED: Files endpoint validation succeeded")
8087
exit(0)
8188
else:
82-
print(f"\n❌ Test FAILED: Expected status 200, got {response.status_code}")
89+
print(
90+
f"\n❌ Test FAILED: Expected status 200, got {response.status_code}"
91+
)
8392
exit(1)
8493

8594
except requests.exceptions.RequestException as e:

0 commit comments

Comments
 (0)