Skip to content

Commit a31b496

Browse files
committed
idempotency tests for parsers for coverage
1 parent c460f65 commit a31b496

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ preserved, so that TyperCommand can be a drop in replacement.
4747

4848
**django-typer makes it easy to:**
4949

50-
* Define your command CLI interface in as clear, DRY, and safely as possible using type hints
50+
* Define your command CLI interface in a clear, DRY and safe way using type hints
5151
* Create subcommand and group command hierarchies.
5252
* Use the full power of Typer's parameter types to validate and parse command line inputs.
5353
* Create beautiful and information dense help outputs.

django_typer/tests/tests.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,10 @@ def test_poll_ex(self):
17831783
class TestShellCompletersAndParsers(TestCase):
17841784
def setUp(self):
17851785
super().setUp()
1786+
self.q1 = Question.objects.create(
1787+
question_text="Is Putin a war criminal?",
1788+
pub_date=timezone.now(),
1789+
)
17861790
for field, values in {
17871791
"char_field": ["jon", "john", "jack", "jason"],
17881792
"text_field": [
@@ -1819,6 +1823,19 @@ def tearDown(self) -> None:
18191823
ShellCompleteTester.objects.all().delete()
18201824
return super().tearDown()
18211825

1826+
def test_model_object_parser_idempotency(self):
1827+
from django_typer.parsers import ModelObjectParser
1828+
from django_typer.tests.polls.models import Question
1829+
1830+
parser = ModelObjectParser(Question)
1831+
self.assertEqual(parser.convert(self.q1, None, None), self.q1)
1832+
1833+
def test_app_label_parser_idempotency(self):
1834+
from django_typer.parsers import parse_app_label
1835+
1836+
poll_app = apps.get_app_config("django_typer_tests_polls")
1837+
self.assertEqual(parse_app_label(poll_app), poll_app)
1838+
18221839
def test_app_label_parser_completers(self):
18231840
from django.apps import apps
18241841

doc/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BaseCommand functionality is preserved, so that TyperCommand can be a drop in re
1010

1111
**django-typer makes it easy to:**
1212

13-
* Define your command CLI interface in as clear, DRY, and safely as possible using type hints
13+
* Define your command CLI interface in a clear, DRY and safe way using type hints
1414
* Create subcommand and group command hierarchies.
1515
* Use the full power of Typer's parameter types to validate and parse command line inputs.
1616
* Create beautiful and information dense help outputs.

0 commit comments

Comments
 (0)