<s> from django . core . exceptions import ValidationError <EOL> from django . test import TestCase <EOL> from taggit_suggest . models import TagKeyword , TagRegex <EOL> from taggit_suggest . utils import suggest_tags <EOL> from taggit . models import Tag <EOL> class SuggestCase ( TestCase ) : <EOL> def test_simple_suggest ( self ) : <EOL> ku_tag = Tag . objects . create ( name = '<STR_LIT>' ) <EOL> TagKeyword . objects . create ( <EOL> tag = ku_tag , <EOL> keyword = '<STR_LIT>' <EOL> ) <EOL> suggested_tags = suggest_tags ( '<STR_LIT>' ) <EOL> self . assertTrue ( ku_tag in suggested_tags ) <EOL> def test_regex_suggest ( self ) : <EOL> ku_tag = Tag . objects . create ( name = '<STR_LIT>' ) <EOL> TagRegex . objects . create ( <EOL> tag = ku_tag , <EOL> name = '<STR_LIT>' , <EOL> regex = '<STR_LIT>' <EOL> ) <EOL> suggested_tags = suggest_tags ( '<STR_LIT>' ) <EOL> self . assertTrue ( ku_tag in suggested_tags ) <EOL> def test_bad_regex ( self ) : <EOL> ku_tag = Tag . objects . create ( name = '<STR_LIT>' ) <EOL> TagKeyword . objects . create ( <EOL> tag = ku_tag , <EOL> keyword = '<STR_LIT>' <EOL> ) <EOL> new_regex = TagRegex ( <EOL> tag = ku_tag , <EOL> name = '<STR_LIT>' , <EOL> regex = '<STR_LIT>' <EOL> ) <EOL> self . assertRaises ( ValidationError , new_regex . save ) <EOL> suggested_tags = suggest_tags ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . assertTrue ( ku_tag in suggested_tags ) </s>
