Coverage for formkit_ninja/management/commands/check_valid_names.py: 0%

1 from django.core.exceptions import ValidationError

2 from django.core.management.base import BaseCommand

3

4 from formkit_ninja.models import FormKitSchemaNode, check_valid_django_id

5

6

7 class Command(BaseCommand):

8 help = "Check node 'name' fields to be valid python identifiers"

9

10 def handle(self, *args, **options):

11 for node in FormKitSchemaNode.objects.all():

12 if node.node and "name" in node.node:

13 name = node.node["name"]

14 try:

15 check_valid_django_id(name)

16 # self.stdout.write(self.style.SUCCESS(name))

17 except (TypeError, ValidationError):

18 self.stdout.write(self.style.WARNING(f"{node.pk}: {name}"))