def test_GIVEN_empty_string_WHEN_validating_field_value_THEN_returns_intermediate_and_emits_signal_with_false( ): validator = FieldValueValidator(object, object) validator.is_valid = Mock() assert validator.validate("", 0) == QValidator.Intermediate validator.is_valid.emit.assert_called_once_with(False)
def test_GIVEN_invalid_float_value_WHEN_validating_field_value_THEN_returns_intermediate_and_emits_signal_with_false(): invalid_value = "sdfn" field_type_combo = DummyCombo(FieldType.scalar_dataset.value) dataset_type_combo = DummyCombo("Float") validator = FieldValueValidator( field_type_combo, dataset_type_combo, FieldType.scalar_dataset.value ) validator.is_valid = Mock() assert validator.validate(invalid_value, 0) == QValidator.Intermediate validator.is_valid.emit.assert_called_once_with(False)
def test_GIVEN_valid_string_value_WHEN_validating_field_value_THEN_returns_acceptable_and_emits_signal_with_true(): strvalue = "123a" field_type_combo = DummyCombo(FieldType.scalar_dataset.value) dataset_type_combo = DummyCombo("String") validator = FieldValueValidator( field_type_combo, dataset_type_combo, FieldType.scalar_dataset.value ) validator.is_valid = Mock() assert validator.validate(strvalue, 0) == QValidator.Acceptable validator.is_valid.emit.assert_called_once_with(True)