|
| 1 | +#!/usr/bin/env python |
| 2 | +""" |
| 3 | +Test script for FoldTree2 conda package |
| 4 | +""" |
| 5 | +import sys |
| 6 | +import subprocess |
| 7 | + |
| 8 | +def test_imports(): |
| 9 | + """Test that all core modules can be imported""" |
| 10 | + print("Testing module imports...") |
| 11 | + try: |
| 12 | + import foldtree2 |
| 13 | + print(" ✓ foldtree2") |
| 14 | + |
| 15 | + import foldtree2.src.encoder |
| 16 | + print(" ✓ foldtree2.src.encoder") |
| 17 | + |
| 18 | + import foldtree2.src.mono_decoders |
| 19 | + print(" ✓ foldtree2.src.mono_decoders") |
| 20 | + |
| 21 | + import foldtree2.src.pdbgraph |
| 22 | + print(" ✓ foldtree2.src.pdbgraph") |
| 23 | + |
| 24 | + print("✓ All core modules imported successfully\n") |
| 25 | + return True |
| 26 | + except ImportError as e: |
| 27 | + print(f"✗ Import failed: {e}\n") |
| 28 | + return False |
| 29 | + |
| 30 | +def test_entry_points(): |
| 31 | + """Test that entry points are available""" |
| 32 | + print("Testing command-line entry points...") |
| 33 | + |
| 34 | + commands = [ |
| 35 | + ['foldtree2', '--about'], |
| 36 | + ['pdbs-to-graphs', '--help'], |
| 37 | + ['makesubmat', '--help'] |
| 38 | + ] |
| 39 | + |
| 40 | + for cmd in commands: |
| 41 | + try: |
| 42 | + result = subprocess.run( |
| 43 | + cmd, |
| 44 | + capture_output=True, |
| 45 | + timeout=10, |
| 46 | + text=True |
| 47 | + ) |
| 48 | + if result.returncode == 0: |
| 49 | + print(f" ✓ Command '{' '.join(cmd)}' works") |
| 50 | + else: |
| 51 | + print(f" ✗ Command '{' '.join(cmd)}' failed with return code {result.returncode}") |
| 52 | + if result.stderr: |
| 53 | + print(f" Error: {result.stderr[:200]}") |
| 54 | + return False |
| 55 | + except subprocess.TimeoutExpired: |
| 56 | + print(f" ✗ Command '{' '.join(cmd)}' timed out") |
| 57 | + return False |
| 58 | + except FileNotFoundError: |
| 59 | + print(f" ✗ Command '{' '.join(cmd)}' not found") |
| 60 | + return False |
| 61 | + except Exception as e: |
| 62 | + print(f" ✗ Command '{' '.join(cmd)}' error: {e}") |
| 63 | + return False |
| 64 | + |
| 65 | + print("✓ All entry points work correctly\n") |
| 66 | + return True |
| 67 | + |
| 68 | +def test_dependencies(): |
| 69 | + """Test that key dependencies are available""" |
| 70 | + print("Testing key dependencies...") |
| 71 | + |
| 72 | + deps = [ |
| 73 | + 'torch', |
| 74 | + 'torch_geometric', |
| 75 | + 'Bio', |
| 76 | + 'pytorch_lightning', |
| 77 | + 'numpy', |
| 78 | + 'pandas' |
| 79 | + ] |
| 80 | + |
| 81 | + for dep in deps: |
| 82 | + try: |
| 83 | + __import__(dep) |
| 84 | + print(f" ✓ {dep}") |
| 85 | + except ImportError: |
| 86 | + print(f" ✗ {dep} not found") |
| 87 | + return False |
| 88 | + |
| 89 | + print("✓ All key dependencies available\n") |
| 90 | + return True |
| 91 | + |
| 92 | +if __name__ == '__main__': |
| 93 | + print("="*60) |
| 94 | + print("FoldTree2 Conda Package Test Suite") |
| 95 | + print("="*60 + "\n") |
| 96 | + |
| 97 | + success = ( |
| 98 | + test_imports() and |
| 99 | + test_dependencies() and |
| 100 | + test_entry_points() |
| 101 | + ) |
| 102 | + |
| 103 | + if success: |
| 104 | + print("="*60) |
| 105 | + print("✓ ALL TESTS PASSED") |
| 106 | + print("="*60) |
| 107 | + sys.exit(0) |
| 108 | + else: |
| 109 | + print("="*60) |
| 110 | + print("✗ SOME TESTS FAILED") |
| 111 | + print("="*60) |
| 112 | + sys.exit(1) |
0 commit comments