Skip to content

Commit ad5d937

Browse files
committed
add parser test to FileField and FilePathField tests
1 parent 37645b5 commit ad5d937

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_parser_completers.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,17 @@ def test_file_field(self):
391391
)
392392
self.assertEqual(completions, ["file3.txt"])
393393

394+
self.assertEqual(
395+
json.loads(call_command("model_fields", "test", "--file", "file3.txt")),
396+
{
397+
"file": {
398+
str(
399+
ShellCompleteTester.objects.get(file_field="file3.txt").pk
400+
): "file3.txt"
401+
}
402+
},
403+
)
404+
394405
def test_file_path_field(self):
395406
completions = get_values(
396407
self.shellcompletion.complete("model_fields test --file-path ")
@@ -417,6 +428,21 @@ def test_file_path_field(self):
417428
)
418429
self.assertEqual(completions, ["dir2/file3.txt"])
419430

431+
self.assertEqual(
432+
json.loads(
433+
call_command("model_fields", "test", "--file-path", "dir2/file3.txt")
434+
),
435+
{
436+
"file_path": {
437+
str(
438+
ShellCompleteTester.objects.get(
439+
file_path_field="dir2/file3.txt"
440+
).pk
441+
): "dir2/file3.txt"
442+
}
443+
},
444+
)
445+
420446
def test_date_field(self):
421447
completions = get_values(
422448
self.shellcompletion.complete("model_fields test --date ")

0 commit comments

Comments
 (0)