Skip to content

Commit 1bef7b6

Browse files
Copilotngocbd
andcommitted
Add test infrastructure validation, improve .gitignore, and enhance Makefile with test targets
Co-authored-by: ngocbd <439333+ngocbd@users.noreply.github.com>
1 parent ff71179 commit 1bef7b6

3 files changed

Lines changed: 168 additions & 3 deletions

File tree

.gitignore

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,55 @@ dump.rdb
3434
.dockerignore
3535

3636
# Kubernetes
37-
*.kubeconfig
37+
*.kubeconfig
38+
39+
# Python
40+
__pycache__/
41+
*.py[cod]
42+
*$py.class
43+
*.so
44+
.Python
45+
build/
46+
develop-eggs/
47+
dist/
48+
downloads/
49+
eggs/
50+
.eggs/
51+
lib/
52+
lib64/
53+
parts/
54+
sdist/
55+
var/
56+
wheels/
57+
*.egg-info/
58+
.installed.cfg
59+
*.egg
60+
MANIFEST
61+
62+
# Testing
63+
.pytest_cache/
64+
.coverage
65+
htmlcov/
66+
.tox/
67+
.nox/
68+
.coverage.*
69+
pytest-report.html
70+
.cache
71+
nosetests.xml
72+
coverage.xml
73+
*.cover
74+
.hypothesis/
75+
76+
# Virtual environments
77+
.env
78+
.venv
79+
env/
80+
venv/
81+
ENV/
82+
env.bak/
83+
venv.bak/
84+
85+
# Test artifacts
86+
tests/.env.test.local
87+
tests/test-results/
88+
tests/artifacts/

Makefile

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ help:
1616
@echo "Development:"
1717
@echo " make dev - Start development server"
1818
@echo " make build - Build the project"
19-
@echo " make test - Run tests"
19+
@echo " make test - Run Rust tests"
20+
@echo " make test-integration - Run integration tests"
21+
@echo " make test-setup - Setup integration test environment"
22+
@echo " make test-clean - Clean integration test environment"
2023
@echo " make check - Check code without building"
2124
@echo " make format - Format code"
2225
@echo " make lint - Run linting"
@@ -76,9 +79,35 @@ build:
7679
@cargo build
7780

7881
test:
79-
@echo "Running tests..."
82+
@echo "Running Rust tests..."
8083
@cargo test
8184

85+
# Integration tests
86+
test-setup:
87+
@echo "Setting up integration test environment..."
88+
@python3 -m pip install -r tests/requirements.txt
89+
@echo "Integration test environment ready"
90+
91+
test-integration: test-setup
92+
@echo "Running integration tests..."
93+
@./tests/run_tests.sh
94+
95+
test-integration-verbose: test-setup
96+
@echo "Running integration tests with verbose output..."
97+
@./tests/run_tests.sh --verbose
98+
99+
test-integration-specific: test-setup
100+
@echo "Running specific integration test..."
101+
@read -p "Enter test pattern: " pattern; \
102+
./tests/run_tests.sh --test "$$pattern"
103+
104+
test-clean:
105+
@echo "Cleaning integration test environment..."
106+
@./tests/run_tests.sh --cleanup-only
107+
108+
test-all: test test-integration
109+
@echo "All tests completed!"
110+
82111
check:
83112
@echo "Checking code..."
84113
@cargo check
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"""
2+
Simple validation test to check if the test infrastructure works
3+
"""
4+
import pytest
5+
import requests
6+
import sys
7+
import os
8+
9+
# Add the project root to the Python path for standalone execution
10+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../..'))
11+
12+
from tests.integrate.conftest import TestConfig, APIClient
13+
14+
15+
def test_config_values():
16+
"""Test that configuration values are set correctly"""
17+
assert TestConfig.BASE_URL == "http://localhost:3000"
18+
assert TestConfig.DB_NAME == "container_engine_test"
19+
assert TestConfig.REDIS_URL == "redis://localhost:6379"
20+
21+
22+
def test_api_client_creation():
23+
"""Test that API client can be created"""
24+
client = APIClient()
25+
assert client.base_url == TestConfig.BASE_URL
26+
assert client.auth_token is None
27+
assert client.api_key is None
28+
29+
30+
def test_api_client_auth_methods():
31+
"""Test API client authentication methods"""
32+
client = APIClient()
33+
34+
# Test setting auth token
35+
client.set_auth_token("test-token")
36+
assert client.auth_token == "test-token"
37+
assert "Authorization" in client.session.headers
38+
assert client.session.headers["Authorization"] == "Bearer test-token"
39+
40+
# Test setting API key
41+
client.set_api_key("test-api-key")
42+
assert client.api_key == "test-api-key"
43+
assert client.session.headers["Authorization"] == "Bearer test-api-key"
44+
45+
# Test clearing auth
46+
client.clear_auth()
47+
assert client.auth_token is None
48+
assert client.api_key is None
49+
assert "Authorization" not in client.session.headers
50+
51+
52+
def test_request_url_construction():
53+
"""Test that request URLs are constructed correctly"""
54+
client = APIClient()
55+
56+
# Mock the request method to check URL construction
57+
original_request = client.session.request
58+
captured_url = None
59+
60+
def mock_request(method, url, **kwargs):
61+
nonlocal captured_url
62+
captured_url = url
63+
# Create a mock response
64+
response = requests.Response()
65+
response.status_code = 200
66+
response._content = b'{"test": "response"}'
67+
return response
68+
69+
client.session.request = mock_request
70+
71+
# Test URL construction
72+
client.get("/test/endpoint")
73+
assert captured_url == "http://localhost:3000/test/endpoint"
74+
75+
# Restore original method
76+
client.session.request = original_request
77+
78+
79+
if __name__ == "__main__":
80+
# Run basic tests
81+
test_config_values()
82+
test_api_client_creation()
83+
test_api_client_auth_methods()
84+
test_request_url_construction()
85+
print("✅ All infrastructure tests passed!")

0 commit comments

Comments
 (0)