Files
FCI_WaterMaker_API/run_dts_test.py

103 lines
3.0 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Simple wrapper script to run DTS API tests with common configurations.
"""
import sys
import os
from dts_api_test_suite import DTSAPITester, TestConfig
def run_basic_test():
"""Run basic DTS test with default settings"""
print("🚀 Running Basic DTS API Test")
print("=" * 50)
# Create tester with default configuration
tester = DTSAPITester()
# Run the test
success = tester.run_test()
if success:
print("\n✅ Test completed successfully!")
return 0
else:
print("\n❌ Test failed!")
return 1
def run_verbose_test():
"""Run DTS test with verbose output and CSV export"""
print("🚀 Running Verbose DTS API Test")
print("=" * 50)
# Create custom configuration
config = TestConfig()
config.CONSOLE_VERBOSITY = "DEBUG"
config.CSV_EXPORT_ENABLED = True
config.POLLING_INTERVAL = 0.5 # More frequent polling
# Create tester
tester = DTSAPITester(config=config)
# Run the test
success = tester.run_test()
if success:
print("\n✅ Verbose test completed successfully!")
return 0
else:
print("\n❌ Verbose test failed!")
return 1
def run_custom_endpoint_test(api_url):
"""Run DTS test against custom API endpoint"""
print(f"🚀 Running DTS API Test against {api_url}")
print("=" * 50)
# Create tester with custom endpoint
tester = DTSAPITester(api_base_url=api_url)
# Run the test
success = tester.run_test()
if success:
print(f"\n✅ Test against {api_url} completed successfully!")
return 0
else:
print(f"\n❌ Test against {api_url} failed!")
return 1
def main():
"""Main entry point with simple command handling"""
if len(sys.argv) < 2:
print("Usage:")
print(" python run_dts_test.py basic # Run basic test")
print(" python run_dts_test.py verbose # Run verbose test with CSV export")
print(" python run_dts_test.py custom <url> # Run test against custom API endpoint")
print("")
print("Examples:")
print(" python run_dts_test.py basic")
print(" python run_dts_test.py verbose")
print(" python run_dts_test.py custom http://192.168.1.100:5000/api")
return 1
command = sys.argv[1].lower()
if command == "basic":
return run_basic_test()
elif command == "verbose":
return run_verbose_test()
elif command == "custom":
if len(sys.argv) < 3:
print("❌ Error: Custom command requires API URL")
print("Usage: python run_dts_test.py custom <api_url>")
return 1
api_url = sys.argv[2]
return run_custom_endpoint_test(api_url)
else:
print(f"❌ Error: Unknown command '{command}'")
print("Available commands: basic, verbose, custom")
return 1
if __name__ == "__main__":
sys.exit(main())