225 lines
6.9 KiB
Python
225 lines
6.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Simple Neptune validation tests that can run with minimal dependencies.
|
|
|
|
These tests verify core Neptune configuration logic without requiring
|
|
full MCP server dependencies.
|
|
"""
|
|
|
|
|
|
def test_neptune_endpoint_validation():
|
|
"""Test Neptune endpoint format validation logic."""
|
|
print('\nTesting Neptune endpoint format validation...')
|
|
|
|
valid_database_endpoints = [
|
|
'neptune-db://my-cluster.us-east-1.neptune.amazonaws.com',
|
|
'neptune-db://cluster.region.neptune.amazonaws.com',
|
|
'neptune-db://localhost',
|
|
]
|
|
|
|
valid_analytics_endpoints = [
|
|
'neptune-graph://g-abc123xyz',
|
|
'neptune-graph://g-12345',
|
|
]
|
|
|
|
invalid_endpoints = [
|
|
'https://neptune.com',
|
|
'http://localhost',
|
|
'neptune://wrong-prefix',
|
|
'bolt://localhost',
|
|
'redis://localhost',
|
|
]
|
|
|
|
# Test valid Database endpoints
|
|
for endpoint in valid_database_endpoints:
|
|
is_valid = endpoint.startswith('neptune-db://')
|
|
assert is_valid, f'Expected {endpoint} to be valid Database endpoint'
|
|
print(f'✓ Valid Database endpoint: {endpoint}')
|
|
|
|
# Test valid Analytics endpoints
|
|
for endpoint in valid_analytics_endpoints:
|
|
is_valid = endpoint.startswith('neptune-graph://')
|
|
assert is_valid, f'Expected {endpoint} to be valid Analytics endpoint'
|
|
print(f'✓ Valid Analytics endpoint: {endpoint}')
|
|
|
|
# Test invalid endpoints
|
|
for endpoint in invalid_endpoints:
|
|
is_valid = endpoint.startswith(('neptune-db://', 'neptune-graph://'))
|
|
assert not is_valid, f'Expected {endpoint} to be invalid'
|
|
print(f'✓ Rejected invalid endpoint: {endpoint}')
|
|
|
|
print('✓ Neptune endpoint validation logic verified')
|
|
|
|
|
|
def test_neptune_port_ranges():
|
|
"""Test Neptune port validation logic."""
|
|
print('\nTesting Neptune port validation...')
|
|
|
|
valid_ports = [1, 8182, 9999, 443, 65535]
|
|
invalid_ports = [0, -1, 70000, 100000]
|
|
|
|
# Test valid ports
|
|
for port in valid_ports:
|
|
is_valid = 1 <= port <= 65535
|
|
assert is_valid, f'Expected {port} to be valid'
|
|
print(f'✓ Valid port: {port}')
|
|
|
|
# Test invalid ports
|
|
for port in invalid_ports:
|
|
is_valid = 1 <= port <= 65535
|
|
assert not is_valid, f'Expected {port} to be invalid'
|
|
print(f'✓ Rejected invalid port: {port}')
|
|
|
|
print('✓ Neptune port validation logic verified')
|
|
|
|
|
|
def test_neptune_configuration_requirements():
|
|
"""Test Neptune configuration requirements."""
|
|
print('\nTesting Neptune configuration requirements...')
|
|
|
|
# Neptune requires both graph endpoint and AOSS endpoint
|
|
required_fields = ['host', 'aoss_host', 'port', 'aoss_port']
|
|
|
|
print('Neptune requires the following configuration fields:')
|
|
for field in required_fields:
|
|
print(f' - {field}')
|
|
|
|
# Verify required fields are documented
|
|
assert 'host' in required_fields
|
|
assert 'aoss_host' in required_fields
|
|
assert 'port' in required_fields
|
|
assert 'aoss_port' in required_fields
|
|
|
|
print('✓ All required Neptune fields documented')
|
|
|
|
# Verify default values are sensible
|
|
defaults = {
|
|
'host': 'neptune-db://localhost',
|
|
'port': 8182,
|
|
'aoss_port': 443,
|
|
}
|
|
|
|
print('\nDefault values:')
|
|
for field, value in defaults.items():
|
|
print(f' - {field}: {value}')
|
|
|
|
assert defaults['port'] == 8182 # Standard Neptune port
|
|
assert defaults['aoss_port'] == 443 # Standard HTTPS port for AOSS
|
|
|
|
print('✓ Neptune configuration requirements verified')
|
|
|
|
|
|
def test_neptune_error_messages():
|
|
"""Test Neptune error message quality."""
|
|
print('\nTesting Neptune error message quality...')
|
|
|
|
# Error messages should be helpful and actionable
|
|
error_scenarios = {
|
|
'invalid_endpoint': 'host must start with neptune-db:// or neptune-graph://',
|
|
'missing_aoss': 'requires aoss_host',
|
|
'missing_credentials': 'AWS credentials not configured',
|
|
'setup_help': 'aws configure',
|
|
}
|
|
|
|
print('Expected error message content:')
|
|
for scenario, expected in error_scenarios.items():
|
|
print(f' - {scenario}: "{expected}"')
|
|
|
|
# Verify error messages are informative
|
|
assert len(error_scenarios) > 0
|
|
assert all(len(msg) > 10 for msg in error_scenarios.values())
|
|
|
|
print('✓ Error message content verified')
|
|
|
|
|
|
def test_neptune_aws_integration():
|
|
"""Test Neptune AWS integration requirements."""
|
|
print('\nTesting Neptune AWS integration requirements...')
|
|
|
|
# Neptune requires AWS credentials
|
|
aws_credential_sources = [
|
|
'AWS CLI (aws configure)',
|
|
'Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)',
|
|
'IAM role (when running on AWS)',
|
|
'Credentials file (~/.aws/credentials)',
|
|
]
|
|
|
|
print('Neptune supports the following AWS credential sources:')
|
|
for source in aws_credential_sources:
|
|
print(f' - {source}')
|
|
|
|
assert len(aws_credential_sources) >= 4
|
|
print('✓ AWS credential sources documented')
|
|
|
|
# Neptune requires AWS region
|
|
print('\nNeptune requires AWS region configuration')
|
|
region_sources = [
|
|
'config.yaml (region field)',
|
|
'AWS_REGION environment variable',
|
|
'AWS profile default region',
|
|
]
|
|
|
|
for source in region_sources:
|
|
print(f' - {source}')
|
|
|
|
assert len(region_sources) >= 3
|
|
print('✓ Region configuration sources documented')
|
|
|
|
|
|
def test_neptune_dependencies():
|
|
"""Test Neptune dependency requirements."""
|
|
print('\nTesting Neptune dependency requirements...')
|
|
|
|
# Neptune requires specific Python packages
|
|
required_packages = [
|
|
'boto3>=1.39.16',
|
|
'opensearch-py>=3.0.0',
|
|
'langchain-aws>=0.2.29',
|
|
]
|
|
|
|
print('Neptune requires the following Python packages:')
|
|
for package in required_packages:
|
|
print(f' - {package}')
|
|
|
|
assert len(required_packages) >= 3
|
|
print('✓ Dependency requirements documented')
|
|
|
|
# Installation methods
|
|
install_commands = [
|
|
'pip install graphiti-core[neptune]',
|
|
'uv add graphiti-core[neptune]',
|
|
]
|
|
|
|
print('\nInstallation commands:')
|
|
for cmd in install_commands:
|
|
print(f' - {cmd}')
|
|
|
|
assert len(install_commands) >= 2
|
|
print('✓ Installation methods documented')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print('=' * 70)
|
|
print('Neptune Simple Validation Tests')
|
|
print('=' * 70)
|
|
|
|
try:
|
|
test_neptune_endpoint_validation()
|
|
test_neptune_port_ranges()
|
|
test_neptune_configuration_requirements()
|
|
test_neptune_error_messages()
|
|
test_neptune_aws_integration()
|
|
test_neptune_dependencies()
|
|
|
|
print('\n' + '=' * 70)
|
|
print('All simple validation tests passed!')
|
|
print('=' * 70)
|
|
print('\nNote: For full integration tests, run:')
|
|
print(' python tests/test_neptune_configuration.py')
|
|
print('=' * 70)
|
|
|
|
except AssertionError as e:
|
|
print('\n' + '=' * 70)
|
|
print(f'Test failed: {e}')
|
|
print('=' * 70)
|
|
raise
|