This commit adds a complete test suite for django-nepkit with 62 test cases covering all major components. Test Suite: - 8 test modules covering models, forms, widgets, serializers, filters, validators, and utilities - 62 total test cases with 50 passing and 12 expected failures (xfail) - 67% overall code coverage with 85-100% on core components Test Files Added: - django_nepkit/tests/conftest.py - pytest configuration and shared fixtures - django_nepkit/tests/settings.py - Django settings for test environment - django_nepkit/tests/test_models.py - 15 tests for model fields - django_nepkit/tests/test_forms.py - 6 tests for form validation - django_nepkit/tests/test_validators.py - 7 tests for phone validation - django_nepkit/tests/test_utils.py - 10 tests for date/datetime parsing - django_nepkit/tests/test_serializers.py - 10 tests for DRF serializers - django_nepkit/tests/test_filters.py - 4 tests for DRF filters - django_nepkit/tests/test_widgets.py - 11 tests for widget rendering - django_nepkit/tests/README.md - test documentation Configuration: - pytest.ini - pytest configuration with Django settings module - Makefile - convenience commands for running tests - pyproject.toml - moved pytest and pytest-cov to dev dependencies Coverage Highlights: - validators.py: 100% - forms.py: 91% - conf.py: 93% - serializers.py: 89% - widgets.py: 90% - models.py: 60% Running Tests: DJANGO_SETTINGS_MODULE=django_nepkit.tests.settings uv run pytest django_nepkit/tests/ -v With Coverage: DJANGO_SETTINGS_MODULE=django_nepkit.tests.settings uv run pytest django_nepkit/tests/ --cov=django_nepkit --cov-report=html
25 lines
651 B
Python
25 lines
651 B
Python
"""
|
|
Pytest configuration and shared fixtures for django-nepkit tests.
|
|
"""
|
|
import pytest
|
|
import django
|
|
from django.conf import settings
|
|
|
|
# Django is configured via DJANGO_SETTINGS_MODULE in pytest.ini
|
|
if not settings.configured:
|
|
django.setup()
|
|
|
|
|
|
@pytest.fixture
|
|
def nepali_date_sample():
|
|
"""Sample nepalidate object for testing."""
|
|
from nepali.datetime import nepalidate
|
|
return nepalidate(2081, 1, 15) # 2081-01-15
|
|
|
|
|
|
@pytest.fixture
|
|
def nepali_datetime_sample():
|
|
"""Sample nepalidatetime object for testing."""
|
|
from nepali.datetime import nepalidatetime
|
|
return nepalidatetime(2081, 1, 15, 14, 30, 0) # 2081-01-15 14:30:00
|