Пример #1
0
def test_keywords_form_field_clean_repeated_semicolons(tag_string, tag_list):
    kwf = KeywordsField()

    # Repeated a semicolon
    first, semicolon, remainder = tag_string.partition(';')
    modified = first + semicolon + semicolon + remainder

    # Add a trailing semicolon, not repeated
    modified += semicolon

    data = kwf.clean(modified)
    assert data == tag_list
Пример #2
0
def test_keywords_form_field_clean_repeated_semicolons(tag_string, tag_list):
    kwf = KeywordsField()

    # Repeated a semicolon
    first, semicolon, remainder = tag_string.partition(';')
    modified = first + semicolon + semicolon + remainder

    # Add a trailing semicolon, not repeated
    modified += semicolon

    data = kwf.clean(modified)
    assert data == tag_list
Пример #3
0
def test_keywords_form_field_clean_none():
    kwf = KeywordsField(required=False)
    data = kwf.clean(None)
    assert data == []
Пример #4
0
def test_keywords_form_field_clean_required():
    kwf = KeywordsField()
    with pytest.raises(ValidationError):
        kwf.clean('')
Пример #5
0
def test_keywords_form_field_clean_unsorted(tag_list):
    unsorted_string = '; '.join(reversed(tag_list))
    kwf = KeywordsField()
    data = kwf.clean(unsorted_string)
    assert data == tag_list
Пример #6
0
def test_keywords_form_field_clean_good_data(tag_string, tag_list):
    kwf = KeywordsField()
    data = kwf.clean(tag_string)
    assert data == tag_list
Пример #7
0
def test_keywords_form_field_uses_correct_widget():
    kwf = KeywordsField()
    assert isinstance(kwf.widget, KeywordsWidget)
Пример #8
0
def test_keywords_form_field_clean_bad_chars():
    kwf = KeywordsField()
    for c in KeywordsField._NOT_ALLOWED:
        with pytest.raises(ValidationError):
            kwf.clean(c)
Пример #9
0
def test_keywords_form_field_clean_empty_string():
    kwf = KeywordsField(required=False)
    data = kwf.clean('')
    assert data == []
Пример #10
0
def test_keywords_form_field_clean_none():
    kwf = KeywordsField(required=False)
    data = kwf.clean(None)
    assert data == []
Пример #11
0
def test_keywords_form_field_clean_required():
    kwf = KeywordsField()
    with pytest.raises(ValidationError):
        kwf.clean('')
Пример #12
0
def test_keywords_form_field_clean_unsorted(tag_list):
    unsorted_string = '; '.join(reversed(tag_list))
    kwf = KeywordsField()
    data = kwf.clean(unsorted_string)
    assert data == tag_list
Пример #13
0
def test_keywords_form_field_clean_good_data(tag_string, tag_list):
    kwf = KeywordsField()
    data = kwf.clean(tag_string)
    assert data == tag_list
Пример #14
0
def test_keywords_form_field_clean_bad_chars():
    kwf = KeywordsField()
    for c in KeywordsField._NOT_ALLOWED:
        with pytest.raises(ValidationError):
            kwf.clean(c)
Пример #15
0
def test_keywords_form_field_clean_empty_string():
    kwf = KeywordsField(required=False)
    data = kwf.clean('')
    assert data == []