aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/tests')
-rw-r--r--mediagoblin/tests/test_auth.py10
-rw-r--r--mediagoblin/tests/test_tags.py11
-rw-r--r--mediagoblin/tests/test_util.py23
-rw-r--r--mediagoblin/tests/tools.py6
4 files changed, 24 insertions, 26 deletions
diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py
index f00456c4..40961eca 100644
--- a/mediagoblin/tests/test_auth.py
+++ b/mediagoblin/tests/test_auth.py
@@ -22,7 +22,7 @@ from nose.tools import assert_equal
from mediagoblin.auth import lib as auth_lib
from mediagoblin.tests.tools import setup_fresh_app
from mediagoblin import mg_globals
-from mediagoblin.tools import template
+from mediagoblin.tools import template, mail
########################
@@ -171,8 +171,8 @@ def test_register_views(test_app):
assert request.session['user_id'] == unicode(new_user['_id'])
## Make sure we get email confirmation, and try verifying
- assert len(template.EMAIL_TEST_INBOX) == 1
- message = template.EMAIL_TEST_INBOX.pop()
+ assert len(mail.EMAIL_TEST_INBOX) == 1
+ message = mail.EMAIL_TEST_INBOX.pop()
assert message['To'] == 'happygrrl@example.org'
email_context = template.TEMPLATE_TEST_CONTEXT[
'mediagoblin/auth/verification_email.txt']
@@ -254,8 +254,8 @@ def test_register_views(test_app):
'mediagoblin/auth/fp_email_sent.html')
## Make sure link to change password is sent by email
- assert len(template.EMAIL_TEST_INBOX) == 1
- message = template.EMAIL_TEST_INBOX.pop()
+ assert len(mail.EMAIL_TEST_INBOX) == 1
+ message = mail.EMAIL_TEST_INBOX.pop()
assert message['To'] == 'happygrrl@example.org'
email_context = template.TEMPLATE_TEST_CONTEXT[
'mediagoblin/auth/fp_verification_email.txt']
diff --git a/mediagoblin/tests/test_tags.py b/mediagoblin/tests/test_tags.py
index d4628795..a05831c9 100644
--- a/mediagoblin/tests/test_tags.py
+++ b/mediagoblin/tests/test_tags.py
@@ -15,9 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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):
@@ -28,23 +27,23 @@ 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! ') == [
+ 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') == [
+ assert text.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'}]
diff --git a/mediagoblin/tests/test_util.py b/mediagoblin/tests/test_util.py
index cdc62b7d..48fa8669 100644
--- a/mediagoblin/tests/test_util.py
+++ b/mediagoblin/tests/test_util.py
@@ -16,10 +16,9 @@
import email
-from mediagoblin import util
-from mediagoblin.tools import url, translate
+from mediagoblin.tools import common, url, translate, mail, text, testing
-util._activate_testing()
+testing._activate_testing()
def _import_component_testing_method(silly_string):
@@ -28,7 +27,7 @@ def _import_component_testing_method(silly_string):
def test_import_component():
- imported_func = util.import_component(
+ imported_func = common.import_component(
'mediagoblin.tests.test_util:_import_component_testing_method')
result = imported_func('hooobaladoobala')
expected = u"'hooobaladoobala' is the silliest string I've ever seen"
@@ -36,10 +35,10 @@ def test_import_component():
def test_send_email():
- util._clear_test_inboxes()
+ mail._clear_test_inboxes()
# send the email
- util.send_email(
+ mail.send_email(
"sender@mediagoblin.example.org",
["amanda@example.org", "akila@example.org"],
"Testing is so much fun!",
@@ -48,8 +47,8 @@ def test_send_email():
I hope you like unit tests JUST AS MUCH AS I DO!""")
# check the main inbox
- assert len(util.EMAIL_TEST_INBOX) == 1
- message = util.EMAIL_TEST_INBOX.pop()
+ assert len(mail.EMAIL_TEST_INBOX) == 1
+ message = mail.EMAIL_TEST_INBOX.pop()
assert message['From'] == "sender@mediagoblin.example.org"
assert message['To'] == "amanda@example.org, akila@example.org"
assert message['Subject'] == "Testing is so much fun!"
@@ -58,8 +57,8 @@ I hope you like unit tests JUST AS MUCH AS I DO!""")
I hope you like unit tests JUST AS MUCH AS I DO!"""
# Check everything that the FakeMhost.sendmail() method got is correct
- assert len(util.EMAIL_TEST_MBOX_INBOX) == 1
- mbox_dict = util.EMAIL_TEST_MBOX_INBOX.pop()
+ assert len(mail.EMAIL_TEST_MBOX_INBOX) == 1
+ mbox_dict = mail.EMAIL_TEST_MBOX_INBOX.pop()
assert mbox_dict['from'] == "sender@mediagoblin.example.org"
assert mbox_dict['to'] == ["amanda@example.org", "akila@example.org"]
mbox_message = email.message_from_string(mbox_dict['message'])
@@ -107,7 +106,7 @@ def test_locale_to_lower_lower():
def test_html_cleaner():
# Remove images
- result = util.clean_html(
+ result = text.clean_html(
'<p>Hi everybody! '
'<img src="http://example.org/huge-purple-barney.png" /></p>\n'
'<p>:)</p>')
@@ -118,7 +117,7 @@ def test_html_cleaner():
'</div>')
# Remove evil javascript
- result = util.clean_html(
+ result = text.clean_html(
'<p><a href="javascript:nasty_surprise">innocent link!</a></p>')
assert result == (
'<p><a href="">innocent link!</a></p>')
diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py
index 308e83ee..cf84da14 100644
--- a/mediagoblin/tests/tools.py
+++ b/mediagoblin/tests/tools.py
@@ -21,7 +21,7 @@ import os, shutil
from paste.deploy import loadapp
from webtest import TestApp
-from mediagoblin import util
+from mediagoblin.tools import testing
from mediagoblin.init.config import read_mediagoblin_config
from mediagoblin.decorators import _make_safe
from mediagoblin.db.open import setup_connection_and_db_from_config
@@ -59,7 +59,7 @@ def get_test_app(dump_old_app=True):
suicide_if_bad_celery_environ()
# Make sure we've turned on testing
- util._activate_testing()
+ testing._activate_testing()
# Leave this imported as it sets up celery.
from mediagoblin.init.celery import from_tests
@@ -117,7 +117,7 @@ def setup_fresh_app(func):
"""
def wrapper(*args, **kwargs):
test_app = get_test_app()
- util.clear_test_buckets()
+ testing.clear_test_buckets()
return func(test_app, *args, **kwargs)
return _make_safe(wrapper, func)