X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=mediagoblin%2Ftests%2Ftest_tags.py;h=e25cc283fe1184b19d9c53dd8c0dd940384e2f70;hb=86ba41688332e3f71779f76c486889a7a099fa91;hp=fa6beca999a15d6969ece3e2396600b5e9e3ca24;hpb=8ff4dec742d0b9f375afd9d1862a560e1be200d1;p=mediagoblin.git diff --git a/mediagoblin/tests/test_tags.py b/mediagoblin/tests/test_tags.py index fa6beca9..e25cc283 100644 --- a/mediagoblin/tests/test_tags.py +++ b/mediagoblin/tests/test_tags.py @@ -1,5 +1,5 @@ # GNU MediaGoblin -- federated, autonomous media hosting -# Copyright (C) 2011 Free Software Foundation, Inc +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -14,12 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from mediagoblin.tests.tools import setup_fresh_app -from mediagoblin import util -from mediagoblin import mg_globals +from mediagoblin.tools import text - -@setup_fresh_app def test_list_of_dicts_conversion(test_app): """ When the user adds tags to a media entry, the string from the form is @@ -28,30 +24,16 @@ def test_list_of_dicts_conversion(test_app): function performs the reverse operation when populating a form to edit tags. """ # Leading, trailing, and internal whitespace should be removed and slugified - assert util.convert_to_tag_list_of_dicts('sleep , 6 AM, chainsaw! ') == [ - {'name': u'sleep', 'slug': u'sleep'}, - {'name': u'6 am', 'slug': u'6-am'}, - {'name': u'chainsaw!', 'slug': u'chainsaw'}] - - # Make sure case-sensitivity is retained when desired - mg_globals.app_config['tags_case_sensitive'] = True - assert util.convert_to_tag_list_of_dicts('sleep , 6 AM, chainsaw! ') == [ + assert text.convert_to_tag_list_of_dicts('sleep , 6 AM, chainsaw! ') == [ {'name': u'sleep', 'slug': u'sleep'}, {'name': u'6 AM', 'slug': u'6-am'}, {'name': u'chainsaw!', 'slug': u'chainsaw'}] # If the user enters two identical tags, record only one of them - assert util.convert_to_tag_list_of_dicts('echo,echo') == [{'name': u'echo', + assert text.convert_to_tag_list_of_dicts('echo,echo') == [{'name': u'echo', 'slug': u'echo'}] # Make sure converting the list of dicts to a string works - assert util.media_tags_as_string([{'name': u'yin', 'slug': u'yin'}, + assert text.media_tags_as_string([{'name': u'yin', 'slug': u'yin'}, {'name': u'yang', 'slug': u'yang'}]) == \ - u'yin,yang' - - # If the tag delimiter is a space then we expect different results - mg_globals.app_config['tags_delimiter'] = u' ' - assert util.convert_to_tag_list_of_dicts('unicorn ceramic nazi') == [ - {'name': u'unicorn', 'slug': u'unicorn'}, - {'name': u'ceramic', 'slug': u'ceramic'}, - {'name': u'nazi', 'slug': u'nazi'}] + u'yin, yang'