예제 #1
0
def test_import_module():
    from inyoka.core.auth import models
    # import definite modules
    assert_true(models is list(_import_module('inyoka.core.auth.models'))[0])
    # star import packages
    assert_true(models in list(_import_module('inyoka.core.*')))
    # star import to definite modules not packages
    # we assert here to import the module rather than to raise a ValueError
    # as werkzeug's find_modules would do.
    list(_import_module('werkzeug._internal.*'))
예제 #2
0
def test_import_module():
    from inyoka.core.auth import models
    # import definite modules
    assert_true(models is list(_import_module('inyoka.core.auth.models'))[0])
    # star import packages
    assert_true(models in list(_import_module('inyoka.core.*')))
    # star import to definite modules not packages
    # we assert here to import the module rather than to raise a ValueError
    # as werkzeug's find_modules would do.
    list(_import_module('werkzeug._internal.*'))
예제 #3
0
def test_components():
    assert_true(Interface1._isinterface)
    assert_false(hasattr(Interface1, '_interfaces'))
    assert_false(Implementation1._isinterface)
    eq_(Implementation1._interfaces, set([Interface1]))
    eq_(Implementation2._interfaces, set([Interface1, Interface2]))

    # we return the component object unchanged so it does not
    # have any special attributes
    obj = Interface(ctx)
    assert_false(hasattr(obj, '_isinterface'))
    assert_false(hasattr(obj, '_interfaces'))
예제 #4
0
def test_components():
    assert_true(Interface1._isinterface)
    assert_false(hasattr(Interface1, '_interfaces'))
    assert_false(Implementation1._isinterface)
    eq_(Implementation1._interfaces, set([Interface1]))
    eq_(Implementation2._interfaces, set([Interface1, Interface2]))

    # we return the component object unchanged so it does not
    # have any special attributes
    obj = Interface(ctx)
    assert_false(hasattr(obj, '_isinterface'))
    assert_false(hasattr(obj, '_interfaces'))
예제 #5
0
def test_component_is_activated():
    assert_false(ctx.component_is_activated(Implementation1, ['tests.core.*']))
    assert_false(ctx.component_is_activated(Implementation1,
                                ['tests.core.test_components.Implementation1']))

    assert_true(ctx.component_is_activated(Implementation2,
                                ['tests.core.test_components.Implementation1']))

    eq_(ctx.load_packages(['tests.core.test_components'], ['tests.core.*']),
                          set([]))

    eq_(ctx.load_packages(['tests.core.test_components'],
                          ['tests.core.test_components.Implementation1']),
                          set([Implementation2, Implementation3]))
예제 #6
0
def test_component_is_activated():
    assert_false(ctx.component_is_activated(Implementation1, ['tests.core.*']))
    assert_false(
        ctx.component_is_activated(
            Implementation1, ['tests.core.test_components.Implementation1']))

    assert_true(
        ctx.component_is_activated(
            Implementation2, ['tests.core.test_components.Implementation1']))

    eq_(ctx.load_packages(['tests.core.test_components'], ['tests.core.*']),
        set([]))

    eq_(
        ctx.load_packages(['tests.core.test_components'],
                          ['tests.core.test_components.Implementation1']),
        set([Implementation2, Implementation3]))
예제 #7
0
def test_load_components():
    loaded = ctx.load_components([Implementation1, Implementation2, Implementation3])
    eq_(len(loaded), 3)

    assert_true(Implementation1 in loaded)
    assert_true(Implementation2 in loaded)
    assert_true(Implementation3 in loaded)
    assert_false(Interface1 in loaded)
    assert_false(Interface2 in loaded)
    assert_false(Interface3 in loaded)

    eq_(len(ctx.get_implementations(Interface1)), 2)
    eq_(len(ctx.get_implementations(Interface2)), 2)
예제 #8
0
def test_load_components():
    loaded = ctx.load_components(
        [Implementation1, Implementation2, Implementation3])
    eq_(len(loaded), 3)

    assert_true(Implementation1 in loaded)
    assert_true(Implementation2 in loaded)
    assert_true(Implementation3 in loaded)
    assert_false(Interface1 in loaded)
    assert_false(Interface2 in loaded)
    assert_false(Interface3 in loaded)

    eq_(len(ctx.get_implementations(Interface1)), 2)
    eq_(len(ctx.get_implementations(Interface2)), 2)