示例#1
0
def test_invalid_field():
    invalid_field = u"ヽヾ"
    field_lookup = FieldLookupBackend()
    with pytest.raises(ValueError) as excinfo:
        field_lookup.value_to_python(WorkflowJobTemplate, invalid_field, 'foo')
    assert 'is not an allowed field name. Must be ascii encodable.' in str(
        excinfo.value)
示例#2
0
def test_invalid_iexact():
    field_lookup = FieldLookupBackend()
    with pytest.raises(ValueError) as excinfo:
        field_lookup.value_to_python(Job, 'id__iexact', '1')
    assert 'is not a text field and cannot be filtered by case-insensitive search' in str(
        excinfo.value)
示例#3
0
def test_valid_iexact():
    field_lookup = FieldLookupBackend()
    value, new_lookup, _ = field_lookup.value_to_python(
        JobTemplate, 'project__name__iexact', 'foo')
    assert 'foo' in value
示例#4
0
def test_empty_in(empty_value):
    field_lookup = FieldLookupBackend()
    with pytest.raises(ValueError) as excinfo:
        field_lookup.value_to_python(JobTemplate, 'project__name__in',
                                     empty_value)
    assert 'empty value for __in' in str(excinfo.value)
示例#5
0
def test_invalid_filter_key():
    field_lookup = FieldLookupBackend()
    # FieldDoesNotExist is caught and converted to ParseError by filter_queryset
    with pytest.raises(FieldDoesNotExist) as excinfo:
        field_lookup.value_to_python(JobEvent, 'event_data.task_action', 'foo')
    assert 'has no field named' in str(excinfo)
示例#6
0
def test_valid_in(valid_value):
    field_lookup = FieldLookupBackend()
    value, new_lookup = field_lookup.value_to_python(JobTemplate, 'project__name__in', valid_value)
    assert 'foo' in value