示例#1
0
 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
示例#2
0
 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
示例#3
0
 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)
示例#4
0
 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
示例#5
0
 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
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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)
示例#9
0
    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)
示例#10
0
    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
示例#11
0
    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
示例#12
0
 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
示例#13
0
 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
示例#14
0
 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)
示例#15
0
 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
示例#16
0
 def test_app_level_view(self):
     view = findview('AppLevelView')
     assert 'newlayout.views.AppLevelView' in str(view), view
示例#17
0
 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
示例#18
0
 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
示例#19
0
 def test_package_component_two_deep(self):
     view = findview('news:InNewsComp2')
     assert 'newscomp2.views.InNewsComp2' in str(view)
示例#20
0
 def test_from_supporting_app_external_component(self):
     view = findview('news:InNewsComp3')
     assert 'newscomp3.views.InNewsComp3' in str(view)
示例#21
0
 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
示例#22
0
 def test_package_component_two_deep(self):
     view = findview('news:InNewsComp2')
     assert 'newscomp2.views.InNewsComp2' in str(view)
示例#23
0
 def test_from_supporting_app_internal_component(self):
     view = findview('news:InNlSupporting')
     assert 'nlsupporting.components.news.views.InNlSupporting' in str(view)
示例#24
0
 def test_package_component(self):
     view = findview('news:InNewsComp1')
     assert 'newscomp1.views.InNewsComp1' in str(view)
示例#25
0
 def test_package_component(self):
     view = findview('news:InNewsComp1')
     assert 'newscomp1.views.InNewsComp1' in str(view)
示例#26
0
 def test_app_level_view(self):
     view = findview('AppLevelView')
     assert 'newlayout.views.AppLevelView' in str(view), view
示例#27
0
 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
示例#28
0
 def test_from_supporting_app_external_component(self):
     view = findview('news:InNewsComp3')
     assert 'newscomp3.views.InNewsComp3' in str(view)
示例#29
0
    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)
示例#30
0
 def test_from_supporting_app_internal_component(self):
     view = findview('news:InNlSupporting')
     assert 'nlsupporting.components.news.views.InNlSupporting' in str(view)
示例#31
0
 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
示例#32
0
    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)