From e418da0358cd2ac8c7f77579523bc0ce5bc60722 Mon Sep 17 00:00:00 2001 From: Guo Zhang Date: Wed, 23 Aug 2023 22:25:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=AE=80=E4=BB=8B?= =?UTF-8?q?=E5=AD=97=E6=AE=B5ReadmeField=EF=BC=8C=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- django_quanttide/models/__init__.py | 3 ++- tests/test_models_fields.py | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/django_quanttide/models/__init__.py b/django_quanttide/models/__init__.py index ac96a7a..37545c7 100644 --- a/django_quanttide/models/__init__.py +++ b/django_quanttide/models/__init__.py @@ -5,7 +5,7 @@ from .choices import StageChoices from .fields import ( IDField, NumberField, NameField, - VerboseNameField, TitleField, DescriptionField, + VerboseNameField, TitleField, DescriptionField, ReadmeField, TypeField, StatusField, StageField, CreatedAtField, UpdatedAtField, CreatedByField, UpdatedByField, @@ -20,6 +20,7 @@ 'VerboseNameField', 'TitleField', 'DescriptionField', + 'ReadmeField', 'TypeField', 'StatusField', 'StageField', diff --git a/tests/test_models_fields.py b/tests/test_models_fields.py index 1cb2655..865a501 100644 --- a/tests/test_models_fields.py +++ b/tests/test_models_fields.py @@ -5,7 +5,7 @@ from django_quanttide.models import ( IDField, NumberField, NameField, - VerboseNameField, TitleField, DescriptionField, + VerboseNameField, TitleField, DescriptionField, ReadmeField, TypeField, StatusField, StageField, StageChoices, CreatedAtField, UpdatedAtField, CreatedByField, UpdatedByField, @@ -112,6 +112,24 @@ def test_custom_options(self): self.assertEqual(field.verbose_name, '关联描述') +class ReadmeFieldTestCase(SimpleTestCase): + + def test_defaults(self): + field = ReadmeField() + self.assertEqual(field.default, None) + self.assertTrue(field.blank) + self.assertTrue(field.null) + self.assertEqual(field.verbose_name, '简介') + + def test_custom_options(self): + field = ReadmeField(default='test', blank=False, null=False, verbose_name='关联简介') + self.assertEqual(field.default, 'test') + self.assertFalse(field.blank) + self.assertFalse(field.null) + self.assertEqual(field.verbose_name, '关联简介') + + + class TypeFieldTestCase(SimpleTestCase): def test_defaults(self):