Пример #1
0
def test_check_first_fail(check_foobar):
    with pytest.raises(factory.NoMatchingCallable):
        factory.get_by_standard_layout(BASE_PKG, 'model',
                                       search_list=SEARCH_LIST,
                                       search_start_value='four',
                                       service=SERVICE,
                                       check=check_foobar,
                                       first_fail=True)
Пример #2
0
def test_feature_import_error():
    # The newest model in this path tries to import something that doesn't
    # exist, in order to genrerate an ImportError distinct from
    # a FactoryLookupError.
    with pytest.raises(ImportError):
        factory.get_by_standard_layout(BASE_PKG, 'model',
                                       search_list=SEARCH_LIST,
                                       feature=FEATURE)
Пример #3
0
def test_check_first_fail(check_foobar):
    with pytest.raises(factory.NoMatchingCallable):
        factory.get_by_standard_layout(BASE_PKG,
                                       'model',
                                       search_list=SEARCH_LIST,
                                       search_start_value='four',
                                       service=SERVICE,
                                       check=check_foobar,
                                       first_fail=True)
Пример #4
0
def test_feature_import_error():
    # The newest model in this path tries to import something that doesn't
    # exist, in order to genrerate an ImportError distinct from
    # a FactoryLookupError.
    with pytest.raises(ImportError):
        factory.get_by_standard_layout(BASE_PKG,
                                       'model',
                                       search_list=SEARCH_LIST,
                                       feature=FEATURE)
Пример #5
0
def test_other_error():
    # Testing an import error from within the imported file is covered above.
    # We should also allow other sorts of errors to escape unchanged.
    # TODO: Is this correct or should we convert them to FactoryLookupError?

    with pytest.raises(SyntaxError):
        factory.get_by_standard_layout(BASE_PKG, 'action',
                                       search_list=SEARCH_LIST,
                                       service=SERVICE)
Пример #6
0
def test_other_error():
    # Testing an import error from within the imported file is covered above.
    # We should also allow other sorts of errors to escape unchanged.
    # TODO: Is this correct or should we convert them to FactoryLookupError?

    with pytest.raises(SyntaxError):
        factory.get_by_standard_layout(BASE_PKG,
                                       'action',
                                       search_list=SEARCH_LIST,
                                       service=SERVICE)
Пример #7
0
def test_feature_start_after_error_before_expected():
    m = factory.get_by_standard_layout(BASE_PKG, 'model',
                                       search_list=SEARCH_LIST,
                                       search_start_value='two',
                                       feature=FEATURE)
    assert (os.path.join(BASE_PKG, 'features', FEATURE, 'one', 'model.py') in
            m.__file__)
Пример #8
0
def test_feature_start_after_error_before_expected():
    m = factory.get_by_standard_layout(BASE_PKG,
                                       'model',
                                       search_list=SEARCH_LIST,
                                       search_start_value='two',
                                       feature=FEATURE)
    assert (os.path.join(BASE_PKG, 'features', FEATURE, 'one', 'model.py')
            in m.__file__)
Пример #9
0
def test_service_start_on_expected():
    # This test also ensures that we don't do an off-by-one indexing error
    # and skip the starting point.
    m = factory.get_by_standard_layout(BASE_PKG, 'model',
                                       search_list=SEARCH_LIST,
                                       search_start_value='two',
                                       service=SERVICE)
    assert (os.path.join(BASE_PKG, 'services', SERVICE, 'two', 'model.py') in
            m.__file__)
Пример #10
0
def test_service_start_on_expected():
    # This test also ensures that we don't do an off-by-one indexing error
    # and skip the starting point.
    m = factory.get_by_standard_layout(BASE_PKG,
                                       'model',
                                       search_list=SEARCH_LIST,
                                       search_start_value='two',
                                       service=SERVICE)
    assert (os.path.join(BASE_PKG, 'services', SERVICE, 'two', 'model.py')
            in m.__file__)
Пример #11
0
def test_check(check_foobar):
    # Test to make sure we skip modules when a check is supplied.
    # In the ss_fake dir, four/model.py has no class, two/model.py has one.

    m = factory.get_by_standard_layout(BASE_PKG, 'model',
                                       search_list=SEARCH_LIST,
                                       search_start_value='four',
                                       service=SERVICE,
                                       check=check_foobar)
    assert m.__name__ == 'FooBar'
    assert m.__module__ == '.'.join((BASE_PKG, 'services', SERVICE,
                                     'two', 'model'))
Пример #12
0
def test_check(check_foobar):
    # Test to make sure we skip modules when a check is supplied.
    # In the ss_fake dir, four/model.py has no class, two/model.py has one.

    m = factory.get_by_standard_layout(BASE_PKG,
                                       'model',
                                       search_list=SEARCH_LIST,
                                       search_start_value='four',
                                       service=SERVICE,
                                       check=check_foobar)
    assert m.__name__ == 'FooBar'
    assert m.__module__ == '.'.join(
        (BASE_PKG, 'services', SERVICE, 'two', 'model'))
Пример #13
0
def test_monolithic_not_found():
    with pytest.raises(factory.NoModuleFound):
        factory.get_by_standard_layout(BASE_PKG, 'weird',
                                       search_list=SEARCH_LIST,
                                       search_start_value='one')
Пример #14
0
def test_monolithic():
    m = factory.get_by_standard_layout(BASE_PKG, 'weird',
                                       search_list=SEARCH_LIST)
    assert os.path.join(BASE_PKG, 'two', 'weird.py') in m.__file__
Пример #15
0
def test_unversioned_fail():
    with pytest.raises(factory.NoModuleFound):
        factory.get_by_standard_layout(BASE_PKG, 'doesnotexist')
Пример #16
0
def test_unversioned():
    # This form is used when a higher layer of factory calculates
    # the base package.
    m = factory.get_by_standard_layout(BASE_PKG, 'unversioned')
    assert 'unversioned' in unicode(m)
Пример #17
0
def test_unversioned():
    # This form is used when a higher layer of factory calculates
    # the base package.
    m = factory.get_by_standard_layout(BASE_PKG, 'unversioned')
    assert 'unversioned' in unicode(m)
Пример #18
0
def test_not_found():
    with pytest.raises(factory.NoModuleFound):
        factory.get_by_standard_layout(BASE_PKG, 'action',
                                       search_list=SEARCH_LIST,
                                       feature=FEATURE)
Пример #19
0
def test_not_found():
    with pytest.raises(factory.NoModuleFound):
        factory.get_by_standard_layout(BASE_PKG,
                                       'action',
                                       search_list=SEARCH_LIST,
                                       feature=FEATURE)
Пример #20
0
def test_unversioned_fail():
    with pytest.raises(factory.NoModuleFound):
        factory.get_by_standard_layout(BASE_PKG, 'doesnotexist')
Пример #21
0
def test_monolithic_not_found():
    with pytest.raises(factory.NoModuleFound):
        factory.get_by_standard_layout(BASE_PKG,
                                       'weird',
                                       search_list=SEARCH_LIST,
                                       search_start_value='one')
Пример #22
0
def test_monolithic():
    m = factory.get_by_standard_layout(BASE_PKG,
                                       'weird',
                                       search_list=SEARCH_LIST)
    assert os.path.join(BASE_PKG, 'two', 'weird.py') in m.__file__