Skip to content

Commit

Permalink
clean and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed May 14, 2024
1 parent bd9408b commit 946f556
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
10 changes: 8 additions & 2 deletions georiviere/contribution/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
CustomContributionTypeFactory,
CustomContributionTypeFieldFactory,
CustomContributionTypeFloatFieldFactory,
CustomContributionTypeIntegerFieldFactory,
CustomContributionTypeIntegerFieldFactory, CustomContributionTypeStringFieldFactory,
CustomContributionTypeTextFieldFactory,
)


Expand Down Expand Up @@ -99,7 +100,12 @@ def test_value_type_field_help_text_when_instance_exists(self):

class CustomContributionFieldFormTest(TestCase):
def test_schema_string(self):
field = CustomContributionTypeFieldFactory(value_type="string")
field = CustomContributionTypeStringFieldFactory()
form = CustomContributionFieldForm(instance=field)
self.assertIsInstance(form.fields["customization"], JSONFormField)

def test_schema_text(self):
field = CustomContributionTypeTextFieldFactory()
form = CustomContributionFieldForm(instance=field)
self.assertIsInstance(form.fields["customization"], JSONFormField)

Expand Down
13 changes: 13 additions & 0 deletions georiviere/contribution/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,16 @@ def test_type_datetime_schema_without_customization(self):
field.get_field_schema(),
{"type": "string", "format": "date-time", "helpText": "", "title": field.label},
)

def test_dropped_choices_empty(self):
""" If choices is defined but empty, it should not be included in the schema """
field = CustomContributionTypeFieldFactory.create(
value_type=CustomContributionTypeField.FieldTypeChoices.STRING,
customization={
"choices": [],
},
)
self.assertNotIn(
'choices',
field.get_field_schema()["properties"],
)
1 change: 0 additions & 1 deletion georiviere/main/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ def ready(self):
from georiviere.river.models import Stream
for model in apps.get_models():
if issubclass(model, MapEntityMixin) and model != Stream:
print("signal for model {}".format(model))
post_save.connect(signals.save_objects_generate_distance_to_source, sender=model)
post_delete.connect(signals.delete_objects_remove_distance_to_source, sender=model)
2 changes: 1 addition & 1 deletion georiviere/main/management/commands/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def handle(self, *args, **options):
for app in apps.get_app_configs():
try:
load_sql_files(app, 'post')
except Exception:
except Exception: # NOQA
pass
call_command('sync_translation_fields', '--noinput')
call_command('update_translation_fields')

0 comments on commit 946f556

Please sign in to comment.