<commit_before>from nose.tools import assert_equals, assert_raises

from django.utils.functional import curry
from django.core.exceptions import ImproperlyConfigured

from rapidsms.tests.harness import setting
from rapidsms.apps.base import AppBase
from rapidsms.router import *
from rapidsms.router.base import BaseRouter


class MockRouter(object):
    pass


def test_import_class():
    assert_raises(ImproperlyConfigured, import_class,
                  'rapidsms.tests.test_router.BadClassName')
    assert_raises(ImproperlyConfigured, import_class,
                  'rapidsms.tests.bad_module.MockRouter')
    assert_equals(import_class('rapidsms.tests.router.test_base.MockRouter'),
                  MockRouter)


def test_get_router():
    with setting(RAPIDSMS_ROUTER='rapidsms.tests.test_router.BadClassName'):
        assert_raises(ImproperlyConfigured, get_router)
    with setting(RAPIDSMS_ROUTER='rapidsms.tests.bad_module.MockRouter'):
        assert_raises(ImproperlyConfigured, get_router)
    with setting(RAPIDSMS_ROUTER='rapidsms.tests.router.test_base.MockRouter'):
        assert_equals(get_router(), MockRouter)


def test_get_test_router():
    with setting(TEST_RAPIDSMS_ROUTER='rapidsms.tests.test_router.BadClassName'):
        assert_raises(ImproperlyConfigured, get_test_router)
    with setting(TEST_RAPIDSMS_ROUTER='rapidsms.tests.bad_module.MockRouter'):
        assert_raises(ImproperlyConfigured, get_test_router)
    with setting(TEST_RAPIDSMS_ROUTER='rapidsms.tests.router.test_base.MockRouter'):
        assert_equals(get_test_router(), MockRouter)


def test_router_calls_all_app_phases():<commit_msg>fail for the right reason<commit_after>from nose.tools import assert_equals, assert_raises

from django.utils.functional import curry
from django.core.exceptions import ImproperlyConfigured

from rapidsms.tests.harness import setting
from rapidsms.apps.base import AppBase
from rapidsms.router import *
from rapidsms.router.base import BaseRouter


class MockRouter(object):
    pass


def test_import_class():
    assert_raises(ImproperlyConfigured, import_class,
                  'rapidsms.tests.router.test_router.BadClassName')
    assert_raises(ImproperlyConfigured, import_class,
                  'rapidsms.tests.router.bad_module.MockRouter')
    assert_equals(import_class('rapidsms.tests.router.test_base.MockRouter'),
                  MockRouter)


def test_get_router():
    with setting(RAPIDSMS_ROUTER='rapidsms.tests.router.test_router.BadClassName'):
        assert_raises(ImproperlyConfigured, get_router)
    with setting(RAPIDSMS_ROUTER='rapidsms.tests.router.bad_module.MockRouter'):
        assert_raises(ImproperlyConfigured, get_router)
    with setting(RAPIDSMS_ROUTER='rapidsms.tests.router.test_base.MockRouter'):
        assert_equals(get_router(), MockRouter)


def test_get_test_router():
    with setting(TEST_RAPIDSMS_ROUTER='rapidsms.tests.router.test_router.BadClassName'):
        assert_raises(ImproperlyConfigured, get_test_router)
    with setting(TEST_RAPIDSMS_ROUTER='rapidsms.tests.router.bad_module.MockRouter'):
        assert_raises(ImproperlyConfigured, get_test_router)
    with setting(TEST_RAPIDSMS_ROUTER='rapidsms.tests.router.test_base.MockRouter'):
        assert_equals(get_test_router(), MockRouter)


def test_router_calls_all_app_phases():
{'fraction_non_alphanumeric': 0.08508088675853805, 'fraction_numerical': 0.0, 'mean_word_length': 5.126605504587156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5816308', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1048, 'n_words': 145}