def test_validate_bad_max_length_fail(self): with pytest.raises(exceptions.InfluxDBAttributeValueError): attr = attributes.StringFieldAttribute(max_length=5) attr.set_internal_value('test_value')
def test_validate_invalid_negative_max_length_fail(self): with pytest.raises(exceptions.InfluxDBAttributeValueError): attributes.StringFieldAttribute(max_length=-7)
def test_validate_bad_choice_type_fail(self): with pytest.raises(exceptions.InfluxDBAttributeValueError): attr = attributes.StringFieldAttribute(choices=['first', 'last']) attr.set_internal_value('ok')
def test_validate_invalid_choices_item_type_fail(self): with pytest.raises(exceptions.InfluxDBAttributeValueError): attributes.StringFieldAttribute(choices=[5, 2, 3])
def test_to_influx_success(self): attr = attributes.StringFieldAttribute() assert attr.to_influx('5') == "\'5\'"
def test_to_python_success(self): attr = attributes.StringFieldAttribute() assert attr.to_python(5) == '5'