Skip to content

Commit f728aa2

Browse files
authored
Merge pull request #208 from VariantEffect/bugfix/bencap/207/target-label-can-be-none
Only Sanitize Target Labels if they are a String
2 parents c1d6333 + 5611c20 commit f728aa2

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/mavedb/view_models/target_sequence.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ def label_does_not_include_colon(cls, field_value, values, field, config) -> str
4949
if ":" in field_value:
5050
raise ValidationError(f"Target sequence label `{field_value}` may not contain a colon.")
5151

52-
# Sanitize the label by stripping leading/trailing whitespace and replacing any internal whitespace with
53-
# underscores. Fully qualified variants should never contain whitespace.
54-
return sanitize_target_sequence_label(field_value)
52+
# Sanitize the label by stripping leading/trailing whitespace and replacing any internal whitespace with
53+
# underscores. Fully qualified variants should never contain whitespace.
54+
return sanitize_target_sequence_label(field_value)
55+
56+
return field_value
5557

5658

5759
class TargetSequenceCreate(TargetSequenceModify):

tests/view_models/test_target_sequence.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ def test_target_sequence_label_is_sanitized():
5858
assert target_sequence.label == sanitize_target_sequence_label(label)
5959

6060

61+
def test_target_sequence_label_can_be_nonetype():
62+
sequence_type = "dna"
63+
label = None
64+
sequence = SEQUENCE
65+
taxonomy = TAXONOMY
66+
67+
target_sequence = TargetSequenceCreate(
68+
sequence_type=sequence_type, sequence=sequence, taxonomy=taxonomy, label=label
69+
)
70+
71+
assert target_sequence.sequence_type == sequence_type
72+
assert target_sequence.sequence == SEQUENCE
73+
assert target_sequence.label is None
74+
75+
6176
def test_cannot_create_target_sequence_with_label_containing_colon():
6277
sequence_type = "dna"
6378
label = "sequence:label"

0 commit comments

Comments
 (0)