This is the SynonymType portion of validating SynonymType.validation_regular_expression. Updating any SynonymType's validation_regex should first check that there is no conflict with any associated Synonym.identifiers.
This ticket is not responsible for checking if updated Synonyms are valid on upload.
Tests:
validation_regular_expression="^.*$ allows all strings.
validation_regular_expression="^[0-9]*$" only allows synonym identifiers with numeric strings.
Updating from the less restrictive regex to the more restrictive regex should throw an error containing any violations.
Below is a simple test that could be run in manage.py shell
synonym_type = SynonymTypeFactory(validation_regular_expression="^.*$").instance
SynonymFactory(identifier="Foobar", synonym_type={"type": "synonymType", "id": synonym_type.pk})
from chemreg.substance.serializers import SynonymTypeSerializer
# partial updates require pulling the SynonymTypeSerializer.
synonym_type = SynonymTypeSerializer(synonym_type, data={"validation_regular_expression": "^[0-9]*$"},partial=True)
assert not synonym_type.is_valid()
print(synonym_type.errors)
closes #149
This is the SynonymType portion of validating
SynonymType.validation_regular_expression
. Updating any SynonymType's validation_regex should first check that there is no conflict with any associatedSynonym.identifier
s.This ticket is not responsible for checking if updated Synonyms are valid on upload.
Tests:
validation_regular_expression="^.*$
allows all strings.validation_regular_expression="^[0-9]*$"
only allows synonym identifiers with numeric strings. Updating from the less restrictive regex to the more restrictive regex should throw an error containing any violations.Below is a simple test that could be run in
manage.py shell
Working update test