Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Commit 716d1ad

Browse files
committed
chore: update .gitignore and Makefile for testing improvements
- Added Python-related files to .gitignore to prevent unnecessary commits. - Updated Makefile to enhance testing commands, introducing specific targets for unit, integration, and coverage tests. - Removed the old test runner script in favor of a more structured pytest approach. - Created a new pyproject.toml file to manage project dependencies and configurations. - Added comprehensive test suite structure with unit, integration, and end-to-end tests. - Included test fixtures and utilities for better test management and organization.
1 parent 66e9d25 commit 716d1ad

38 files changed

+9569
-1288
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ webpanel_config/
4545
*.bak
4646
# WebPanel config (part of data)
4747
data/webpanel/config/
48+
49+
50+
# python
51+
__pycache__/
52+
*.pyc
53+
*.pyo
54+
*.pyd
55+
.pytest_cache/
56+
.ruff_cache/
57+
.uv_cache/

Makefile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,39 @@ dev-logs:
186186
# Testing and validation
187187
test:
188188
@echo -e "$(PURPLE)=== Running Comprehensive Tests ===$(NC)"
189-
@echo -e "$(BLUE)[INFO]$(NC) Running environment validation and functionality tests..."
190-
@python3 tests/run_tests.py
189+
@echo -e "$(BLUE)[INFO]$(NC) Running test suite with uv..."
190+
@uv run pytest tests/
191191
@echo -e "$(GREEN)[SUCCESS]$(NC) Test suite completed!"
192192

193193
test-env:
194194
@echo -e "$(PURPLE)=== Environment Validation Tests ===$(NC)"
195195
@echo -e "$(BLUE)[INFO]$(NC) Validating environment setup, permissions, and configuration..."
196-
@python3 tests/test_environment_validation.py --verbose
196+
@uv run pytest tests/unit/test_docker_client.py -v
197197

198198
test-irc:
199199
@echo -e "$(PURPLE)=== IRC Functionality Tests ===$(NC)"
200200
@echo -e "$(BLUE)[INFO]$(NC) Testing IRC server functionality..."
201-
@python3 tests/test_irc_functionality.py
201+
@uv run pytest tests/integration/test_docker_services.py -v
202+
203+
test-unit:
204+
@echo -e "$(PURPLE)=== Unit Tests ===$(NC)"
205+
@echo -e "$(BLUE)[INFO]$(NC) Running unit tests..."
206+
@uv run pytest tests/unit/ -v
207+
208+
test-integration:
209+
@echo -e "$(PURPLE)=== Integration Tests ===$(NC)"
210+
@echo -e "$(BLUE)[INFO]$(NC) Running integration tests..."
211+
@uv run pytest tests/integration/ -v
212+
213+
test-cov:
214+
@echo -e "$(PURPLE)=== Tests with Coverage ===$(NC)"
215+
@echo -e "$(BLUE)[INFO]$(NC) Running tests with coverage report..."
216+
@uv run pytest --cov=src --cov-report=html --cov-report=term-missing
217+
218+
test-docker:
219+
@echo -e "$(PURPLE)=== Docker-related Tests ===$(NC)"
220+
@echo -e "$(BLUE)[INFO]$(NC) Running tests that require Docker..."
221+
@uv run pytest -m docker -v
202222

203223
test-quick:
204224
@echo -e "$(PURPLE)=== Quick Environment Check ===$(NC)"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ cd irc.atl.chat
2121
cp env.example .env
2222

2323
# 2. Edit configuration
24+
# BE SURE TO READ THIS CAREFULLY AND DOUBLE CHECK ALL VARIABLES
2425
vim .env
2526

2627
# 3. Setup Cloudflare DNS credentials

pyproject.toml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
[project]
2+
name = "irc-atl-chat"
3+
version = "0.1.0"
4+
requires-python = ">=3.11"
5+
description = "IRC.atl.chat - Docker-based IRC server with UnrealIRCd and Atheme"
6+
readme = "README.md"
7+
license = "MIT"
8+
authors = [{ name = "All Things Linux", email = "[email protected]" }]
9+
maintainers = [
10+
{ name = "All Things Linux", email = "[email protected]" },
11+
]
12+
13+
14+
# All dependencies (this is a testing/infrastructure project)
15+
dependencies = [
16+
# Core infrastructure
17+
"docker>=7.1.0",
18+
"pyyaml>=6.0.2",
19+
"requests>=2.32.5",
20+
"psutil>=5.9.0",
21+
22+
# IRC libraries
23+
"irc>=20.5.0",
24+
"irc-toolkit>=0.2.0",
25+
"pydle>=1.1.0",
26+
"unrealircd-rpc-py>=2.0.0",
27+
"websocket-client>=1.0.0",
28+
29+
# Testing framework
30+
"pytest>=8.0.0",
31+
"pytest-mock>=3.12.0",
32+
"pytest-asyncio>=0.23.0",
33+
"pytest-xdist>=3.0.0",
34+
"pytest-html>=4.0.0",
35+
"pytest-timeout>=2.4.0",
36+
"pytest-sugar>=1.1.1",
37+
"pytest-docker>=3.0.0",
38+
39+
# Code quality
40+
"ruff>=0.6.0",
41+
"basedpyright>=0.6.0",
42+
"pre-commit>=3.0.0",
43+
]
44+
45+
[project.urls]
46+
repository = "https://github.com/allthingslinux/irc.atl.chat"
47+
homepage = "https://irc.atl.chat"
48+
49+
[tool.pytest.ini_options]
50+
# Test discovery
51+
testpaths = ["tests"]
52+
python_files = ["test_*.py", "*_test.py"]
53+
python_classes = ["Test*"]
54+
python_functions = ["test_*"]
55+
56+
# Default options for all pytest runs
57+
addopts = [
58+
# Output formatting
59+
"--strict-markers",
60+
"--tb=short",
61+
# Verbose logging
62+
"-v",
63+
"--color=yes",
64+
"--durations=10",
65+
# Async support
66+
"--asyncio-mode=auto",
67+
]
68+
69+
# Markers
70+
markers = [
71+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
72+
"integration: marks tests as integration tests",
73+
"unit: marks tests as unit tests",
74+
"docker: marks tests that require Docker",
75+
"irc: marks tests that require IRC server",
76+
"network: marks tests that require network access",
77+
"e2e: marks tests as end-to-end tests",
78+
"atheme: marks tests that require Atheme services",
79+
"webpanel: marks tests that require WebPanel",
80+
"ssl: marks tests that require SSL functionality",
81+
"performance: marks tests as performance tests",
82+
"async: marks tests as async tests",
83+
"protocol: marks tests for IRC protocol compliance",
84+
"unrealircd: marks tests specific to UnrealIRCd",
85+
"ircv3: marks tests for IRCv3 features",
86+
]
87+
88+
# Filter warnings
89+
filterwarnings = ["error", "ignore::UserWarning", "ignore::DeprecationWarning"]
90+
91+
# Minimum version
92+
minversion = "8.0"
93+
94+
# Test timeout (in seconds)
95+
timeout = 300
96+
97+
# AsyncIO configuration
98+
asyncio_mode = "auto"
99+
asyncio_default_fixture_loop_scope = "session"
100+
101+
# Directories to skip during test discovery
102+
norecursedirs = [
103+
".git",
104+
".venv",
105+
"venv",
106+
"__pycache__",
107+
".pytest_cache",
108+
"logs",
109+
"data",
110+
]
111+
112+
[tool.ruff]
113+
exclude = [".venv", "__pycache__", ".pytest_cache", "logs", "data"]
114+
line-length = 120
115+
target-version = "py311"
116+
117+
[tool.ruff.lint]
118+
ignore = [
119+
"E501", # Line too long (handled by formatter)
120+
"PLR0913", # Too many arguments
121+
"PLR2004", # Magic value comparison
122+
]
123+
select = [
124+
"E", # pycodestyle-error
125+
"F", # pyflakes
126+
"I", # isort
127+
"N", # pep8-naming
128+
"UP", # pyupgrade
129+
"B", # flake8-bugbear
130+
"SIM", # flake8-simplify
131+
"PL", # pylint
132+
"RUF", # ruff
133+
]
134+
135+
[tool.ruff.format]
136+
quote-style = "double"
137+
indent-style = "space"
138+
line-ending = "lf"
139+
140+
[tool.mypy]
141+
python_version = "3.11"
142+
warn_return_any = true
143+
warn_unused_configs = true
144+
disallow_untyped_defs = true
145+
disallow_incomplete_defs = true
146+
check_untyped_defs = true
147+
disallow_untyped_decorators = true
148+
no_implicit_optional = true
149+
warn_redundant_casts = true
150+
warn_unused_ignores = true
151+
warn_no_return = true
152+
warn_unreachable = true
153+
strict_equality = true
154+
show_error_codes = true
155+
156+
[tool.uv]
157+
# uv-specific configuration
158+
cache-dir = ".uv_cache"
159+
160+
[[tool.mypy.overrides]]
161+
module = ["docker.*", "irc.*", "pydle.*", "unrealircd_rpc_py.*"]
162+
ignore_missing_imports = true

tests/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# IRC.atl.chat Test Suite
2+
3+
This directory contains the comprehensive test suite for IRC.atl.chat using pytest and uv.
4+
5+
## Structure
6+
7+
- `unit/` - Unit tests for individual components
8+
- `integration/` - Integration tests for component interactions
9+
- `e2e/` - End-to-end tests for complete workflows
10+
- `utils/` - Test utilities and helper functions
11+
- `fixtures/` - Test fixtures and sample data
12+
- `conftest.py` - Shared pytest fixtures and configuration
13+
14+
## Running Tests
15+
16+
### Using Make (Recommended)
17+
```bash
18+
make test # Run all tests
19+
make test-unit # Run unit tests only
20+
make test-integration # Run integration tests only
21+
make test-cov # Run tests with coverage
22+
make test-docker # Run Docker-related tests
23+
```
24+
25+
### Using uv directly
26+
```bash
27+
uv run pytest tests/ # Run all tests
28+
uv run pytest tests/unit/ # Run unit tests
29+
uv run pytest tests/integration/ # Run integration tests
30+
uv run pytest --cov=src # Run with coverage
31+
uv run pytest -m docker # Run Docker tests
32+
uv run pytest -m slow # Run slow tests
33+
```
34+
35+
## Test Markers
36+
37+
- `@pytest.mark.unit` - Unit tests
38+
- `@pytest.mark.integration` - Integration tests
39+
- `@pytest.mark.docker` - Tests requiring Docker
40+
- `@pytest.mark.irc` - Tests requiring IRC server
41+
- `@pytest.mark.slow` - Slow-running tests
42+
- `@pytest.mark.network` - Tests requiring network access
43+
44+
## Configuration
45+
46+
Tests are configured via:
47+
- `pyproject.toml` - pytest configuration and dependencies
48+
- `pytest.ini` - Additional pytest settings
49+
- `.coveragerc` - Coverage configuration
50+
51+
## Fixtures
52+
53+
Common fixtures available:
54+
- `docker_client` - Docker API client
55+
- `project_root` - Project root directory
56+
- `compose_file` - Docker Compose file path
57+
- `irc_helper` - IRC connection helper
58+
- `docker_compose_helper` - Docker Compose operations
59+
- `sample_config_data` - Sample configuration data
60+
61+
## Dependencies
62+
63+
Test dependencies are managed via uv and defined in `pyproject.toml` under `[project.optional-dependencies] test`.

tests/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""IRC.atl.chat test suite."""
2+
3+
__version__ = "0.1.0"

0 commit comments

Comments
 (0)