Skip to content

Commit 27a4d45

Browse files
committed
test(coverage): extend test suite to improve coverage from 57% to 81%
- Add comprehensive tests for config, troubleshoot, and optimize commands - Test error handling decorator with all exception types - Add verbose mode testing for build and watch commands - Include edge case testing for command outputs and status displays - Focus on core functionality without over-mocking using pytest-django capabilities - 19 new test cases in test_additional_commands.py covering previously untested code paths
1 parent 0584014 commit 27a4d45

File tree

9 files changed

+509
-210
lines changed

9 files changed

+509
-210
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
### 🎯 New Features
66
- **Interactive setup command**: `python manage.py tailwind setup` for guided configuration
7-
- **Configuration viewer**: `python manage.py tailwind config` to inspect current settings
7+
- **Configuration viewer**: `python manage.py tailwind config` to inspect current settings
88
- **Troubleshooting guide**: `python manage.py tailwind troubleshoot` for common issues
99
- **Performance tips**: `python manage.py tailwind optimize` for optimization guidance
1010
- **Enhanced verbose mode**: `--verbose` flag for detailed build and watch diagnostics
1111

12-
### ⚡ Performance Improvements
12+
### ⚡ Performance Improvements
1313
- **Smart rebuilds**: File modification checks prevent unnecessary CSS rebuilds
1414
- **Version caching**: 1-hour cache reduces GitHub API requests
1515
- **Process optimization**: Improved `tailwind runserver` with better signal handling
@@ -27,7 +27,7 @@
2727
- **Inline documentation**: Detailed docstrings and usage examples throughout codebase
2828

2929
### 🧪 Quality Assurance
30-
- **Comprehensive testing**: 58+ new tests covering integration workflows and error scenarios
30+
- **Comprehensive testing**: 58+ new tests covering integration workflows and error scenarios
3131
- **Cross-platform support**: Windows, macOS, and Linux compatibility testing
3232
- **89% test coverage**: Robust validation of all major functionality
3333

CONFIGURATION.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,24 @@ jobs:
124124
runs-on: ubuntu-latest
125125
steps:
126126
- uses: actions/checkout@v4
127-
127+
128128
- name: Set up Python
129129
uses: actions/setup-python@v4
130130
with:
131131
python-version: '3.12'
132-
132+
133133
- name: Install uv
134134
uses: astral-sh/setup-uv@v1
135-
135+
136136
- name: Install dependencies
137137
run: uv sync --all-extras
138-
138+
139139
- name: Download Tailwind CLI
140140
run: uv run python manage.py tailwind download_cli
141-
141+
142142
- name: Build CSS
143143
run: uv run python manage.py tailwind build
144-
144+
145145
- name: Run tests
146146
run: uv run pytest
147147
```
@@ -191,7 +191,7 @@ TAILWIND_CLI_SRC_CSS = "src/styles/main.css"
191191
html {
192192
scroll-behavior: smooth;
193193
}
194-
194+
195195
body {
196196
@apply font-sans antialiased;
197197
}
@@ -411,4 +411,4 @@ if not DEBUG:
411411
STATIC_URL = 'https://cdn.example.com/static/'
412412
```
413413

414-
This configuration guide covers the most common advanced scenarios you'll encounter when deploying django-tailwind-cli in production environments.
414+
This configuration guide covers the most common advanced scenarios you'll encounter when deploying django-tailwind-cli in production environments.

DEVELOPMENT.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ python manage.py runserver # Terminal 2: Django server
3535
```html
3636
<!-- templates/myapp/page.html -->
3737
{% extends "base.html" %}
38-
38+
3939
{% block content %}
4040
<div class="max-w-4xl mx-auto p-6">
4141
<h1 class="text-3xl font-bold text-gray-900">New Page</h1>
@@ -279,23 +279,23 @@ from django.core.management import call_command
279279

280280
class Command(BaseCommand):
281281
help = "Complete development environment setup"
282-
282+
283283
def handle(self, *args, **options):
284284
self.stdout.write("Setting up development environment...")
285-
285+
286286
# Run Tailwind setup
287287
call_command('tailwind', 'setup')
288-
288+
289289
# Build initial CSS
290290
call_command('tailwind', 'build')
291-
291+
292292
# Run migrations
293293
call_command('migrate')
294-
294+
295295
# Create superuser if needed
296-
call_command('createsuperuser', '--noinput',
296+
call_command('createsuperuser', '--noinput',
297297
username='admin', email='admin@example.com')
298-
298+
299299
self.stdout.write(
300300
self.style.SUCCESS("Development environment ready!")
301301
)
@@ -347,12 +347,12 @@ from django.test import TestCase
347347
from django.template.loader import render_to_string
348348

349349
class TailwindIntegrationTest(TestCase):
350-
350+
351351
def test_base_template_includes_tailwind(self):
352352
"""Test that base template includes Tailwind CSS."""
353353
html = render_to_string('base.html')
354354
self.assertIn('tailwind.css', html)
355-
355+
356356
def test_tailwind_classes_in_template(self):
357357
"""Test that templates use Tailwind classes."""
358358
html = render_to_string('myapp/index.html')
@@ -372,20 +372,20 @@ from django.conf import settings
372372
from pathlib import Path
373373

374374
class TailwindBuildTest(TestCase):
375-
375+
376376
def test_css_build_process(self):
377377
"""Test that CSS builds successfully."""
378378
# Run build command
379379
result = subprocess.run([
380380
'python', 'manage.py', 'tailwind', 'build', '--force'
381381
], capture_output=True, text=True)
382-
382+
383383
self.assertEqual(result.returncode, 0)
384-
384+
385385
# Check that CSS file was created
386386
css_path = Path(settings.STATICFILES_DIRS[0]) / 'css/tailwind.css'
387387
self.assertTrue(css_path.exists())
388-
388+
389389
# Check CSS content
390390
css_content = css_path.read_text()
391391
self.assertIn('@media', css_content) # Should contain media queries
@@ -403,17 +403,17 @@ import subprocess
403403
from django.test import TestCase
404404

405405
class TailwindPerformanceTest(TestCase):
406-
406+
407407
def test_build_performance(self):
408408
"""Test that builds complete within reasonable time."""
409409
start_time = time.time()
410-
410+
411411
result = subprocess.run([
412412
'python', 'manage.py', 'tailwind', 'build', '--force'
413413
], capture_output=True)
414-
414+
415415
build_time = time.time() - start_time
416-
416+
417417
self.assertEqual(result.returncode, 0)
418418
self.assertLess(build_time, 30) # Should build in under 30 seconds
419419
```
@@ -475,4 +475,4 @@ Steps to Reproduce:
475475
3. [etc.]
476476
```
477477

478-
This comprehensive debugging guide should help you resolve most issues and maintain an efficient development workflow with django-tailwind-cli.
478+
This comprehensive debugging guide should help you resolve most issues and maintain an efficient development workflow with django-tailwind-cli.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Start adding Tailwind classes to your templates:
124124

125125
### 🏗️ Build System
126126
- **Automatic CLI download** - No manual setup required
127-
- **Smart caching** - Faster rebuilds with file change detection
127+
- **Smart caching** - Faster rebuilds with file change detection
128128
- **Production optimization** - Automatic CSS purging and minification
129129
- **Force rebuild** - `--force` flag for clean builds
130130

@@ -291,7 +291,7 @@ just test # Run test suite
291291
just test-all # Run tests across Python/Django versions
292292

293293
# Without just
294-
uv sync --all-extras # Update dependencies
294+
uv sync --all-extras # Update dependencies
295295
uvx pre-commit run --all-files # Run linting
296296
uv run pytest # Run tests
297297
uvx --with tox-uv tox # Run full test matrix

src/django_tailwind_cli/apps.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99

1010
class DjangoTailwindCliConfig(AppConfig):
1111
"""Django app configuration for Tailwind CSS CLI integration.
12-
12+
1313
This app provides seamless Tailwind CSS integration for Django projects
1414
without requiring Node.js. It includes:
15-
15+
1616
- Management commands for building and watching CSS files
17-
- Template tags for including Tailwind CSS in templates
17+
- Template tags for including Tailwind CSS in templates
1818
- Automatic CLI binary management
1919
- Development and production optimization features
20-
20+
2121
The app is automatically discovered when 'django_tailwind_cli' is added
2222
to INSTALLED_APPS in Django settings.
23-
23+
2424
Attributes:
2525
default_auto_field: Default primary key field type for models
2626
name: The Python module path for this app
2727
verbose_name: Human-readable name for Django admin and introspection
2828
"""
29-
29+
3030
default_auto_field = "django.db.models.BigAutoField"
3131
name = "django_tailwind_cli"
3232
verbose_name = "Django Tailwind CLI"

0 commit comments

Comments
 (0)