def test_good_component_but_object_not_there(self): try: findview('news:nothere') assert False except HierarchyImportError as e: assert 'An object for View endpoint "news:nothere" was not found' in str( e), e
def test_disabled_component(self): try: findview('pdisabled:FakeView') assert False except HierarchyImportError as e: assert 'An object for View endpoint "pdisabled:FakeView" was not found' in str( e), e
def test_no_setting_component(self): try: findview('pnosetting:FakeView') assert False except HierarchyImportError as e: assert 'An object for View endpoint "pnosetting:FakeView" was not found' in str( e)
def test_find_view_hierarchy_import_errors_get_raised(self): try: findview('badimport1:Index') assert False except HierarchyImportError as e: assert 'module "nothere" not found; searched compstack' in str( e), e
def test_find_view_no_component(self): try: findview('notacomponent:Foo') assert False except HierarchyImportError as e: assert 'An object for View endpoint "notacomponent:Foo" was not found' == str( e), e
def test_package_component_priority(self): # upper external components have priority over lower externals view = findview('news:News1HasPriority') assert 'newscomp1.views.News1HasPriority' in str(view) # components in the application have priority over externals view = findview('news:InAppHasPriority') assert 'newlayout.components.news.views.InAppHasPriority' in str(view)
def test_import_cache(self): eh = logging_handler('blazeweb.hierarchy') view1 = findview('news:OnlyForCache') dmesgs = ''.join(eh.messages['debug']) assert 'in cache' not in dmesgs, dmesgs eh.reset() view2 = findview('news:OnlyForCache') dmesgs = ''.join(eh.messages['debug']) assert 'in cache' in dmesgs, dmesgs assert view1 is view2, (view1, view2)
def test_cache_namespaces(self): # this is contrived example, I know from appstack.news.views import FakeView assert 'newlayout.news.views.FakeView' in str(FakeView), FakeView view = findview('news:FakeView') assert 'newlayout.components.news.views.FakeView' in str(view), view
def dispatch_to_endpoint(self, endpoint, args): log.debug('dispatch to %s (%s)', endpoint, args) if '.' not in endpoint: vklass = findview(endpoint) else: vklass = _RouteToTemplate v = vklass(args, endpoint) response = v.process() return response
def test_no_setting_component(self): try: findview('pnosetting:FakeView') assert False except HierarchyImportError as e: assert 'An object for View endpoint "pnosetting:FakeView" was not found' in str(e)
def test_good_component_but_object_not_there(self): try: findview('news:nothere') assert False except HierarchyImportError as e: assert 'An object for View endpoint "news:nothere" was not found' in str(e), e
def test_app_level_view(self): view = findview('AppLevelView') assert 'newlayout.views.AppLevelView' in str(view), view
def test_disabled_component(self): try: findview('pdisabled:FakeView') assert False except HierarchyImportError as e: assert 'An object for View endpoint "pdisabled:FakeView" was not found' in str(e), e
def test_import_error_in_target_gets_raised(self): try: findview('badimport:nothere') assert False except ImportError as e: assert 'No module named foo' == str(e).replace("'", ''), e
def test_package_component_two_deep(self): view = findview('news:InNewsComp2') assert 'newscomp2.views.InNewsComp2' in str(view)
def test_from_supporting_app_external_component(self): view = findview('news:InNewsComp3') assert 'newscomp3.views.InNewsComp3' in str(view)
def test_find_view_hierarchy_import_errors_get_raised(self): try: findview('badimport1:Index') assert False except HierarchyImportError as e: assert 'module "nothere" not found; searched compstack' in str(e), e
def test_from_supporting_app_internal_component(self): view = findview('news:InNlSupporting') assert 'nlsupporting.components.news.views.InNlSupporting' in str(view)
def test_package_component(self): view = findview('news:InNewsComp1') assert 'newscomp1.views.InNewsComp1' in str(view)
def test_component_view(self): view = findview('news:FakeView') assert 'newlayout.components.news.views.FakeView' in str(view), view from compstack.news.views import FakeView assert view is FakeView, (view, FakeView)
def test_find_view_no_component(self): try: findview('notacomponent:Foo') assert False except HierarchyImportError as e: assert 'An object for View endpoint "notacomponent:Foo" was not found' == str(e), e