updated workflow
This commit is contained in:
10 files changed
+97
-90
No files matched your search
@@ -1,8 +1,8 @@
|
||||
"""
|
||||
Tests for django-nepkit form fields.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from nepali.datetime import nepalidate
|
||||
|
||||
@@ -15,7 +15,7 @@ class TestNepaliDateFormField:
|
||||
def test_valid_date_input(self):
|
||||
"""Test that valid date strings are accepted."""
|
||||
field = NepaliDateFormField()
|
||||
|
||||
|
||||
result = field.clean("2081-01-15")
|
||||
assert isinstance(result, nepalidate)
|
||||
assert result.year == 2081
|
||||
@@ -25,13 +25,13 @@ class TestNepaliDateFormField:
|
||||
def test_multiple_input_formats(self):
|
||||
"""Test that multiple date formats are accepted."""
|
||||
field = NepaliDateFormField()
|
||||
|
||||
|
||||
formats = [
|
||||
"2081-01-15",
|
||||
"15/01/2081",
|
||||
"15-01-2081",
|
||||
]
|
||||
|
||||
|
||||
for date_str in formats:
|
||||
result = field.clean(date_str)
|
||||
assert isinstance(result, nepalidate)
|
||||
@@ -39,14 +39,14 @@ class TestNepaliDateFormField:
|
||||
def test_empty_value_optional(self):
|
||||
"""Test that empty value is accepted for optional fields."""
|
||||
field = NepaliDateFormField(required=False)
|
||||
|
||||
|
||||
result = field.clean("")
|
||||
assert result is None
|
||||
|
||||
def test_empty_value_required(self):
|
||||
"""Test that empty value raises error for required fields."""
|
||||
field = NepaliDateFormField(required=True)
|
||||
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
field.clean("")
|
||||
|
||||
@@ -54,7 +54,7 @@ class TestNepaliDateFormField:
|
||||
def test_invalid_date_format(self):
|
||||
"""Test that invalid date format raises ValidationError."""
|
||||
field = NepaliDateFormField()
|
||||
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
field.clean("invalid-date")
|
||||
|
||||
@@ -62,6 +62,6 @@ class TestNepaliDateFormField:
|
||||
"""Test that nepalidate objects are accepted."""
|
||||
field = NepaliDateFormField()
|
||||
date_obj = nepalidate(2081, 1, 15)
|
||||
|
||||
|
||||
result = field.clean(date_obj)
|
||||
assert result is date_obj
|
||||
Reference in new issue
Block a user