Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 16
0
 def test_app_level_view(self):
     view = findview('AppLevelView')
     assert 'newlayout.views.AppLevelView' in str(view), view
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 19
0
 def test_package_component_two_deep(self):
     view = findview('news:InNewsComp2')
     assert 'newscomp2.views.InNewsComp2' in str(view)
Ejemplo n.º 20
0
 def test_from_supporting_app_external_component(self):
     view = findview('news:InNewsComp3')
     assert 'newscomp3.views.InNewsComp3' in str(view)
Ejemplo n.º 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
Ejemplo n.º 22
0
 def test_package_component_two_deep(self):
     view = findview('news:InNewsComp2')
     assert 'newscomp2.views.InNewsComp2' in str(view)
Ejemplo n.º 23
0
 def test_from_supporting_app_internal_component(self):
     view = findview('news:InNlSupporting')
     assert 'nlsupporting.components.news.views.InNlSupporting' in str(view)
Ejemplo n.º 24
0
 def test_package_component(self):
     view = findview('news:InNewsComp1')
     assert 'newscomp1.views.InNewsComp1' in str(view)
Ejemplo n.º 25
0
 def test_package_component(self):
     view = findview('news:InNewsComp1')
     assert 'newscomp1.views.InNewsComp1' in str(view)
Ejemplo n.º 26
0
 def test_app_level_view(self):
     view = findview('AppLevelView')
     assert 'newlayout.views.AppLevelView' in str(view), view
Ejemplo n.º 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
Ejemplo n.º 28
0
 def test_from_supporting_app_external_component(self):
     view = findview('news:InNewsComp3')
     assert 'newscomp3.views.InNewsComp3' in str(view)
Ejemplo n.º 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)
Ejemplo n.º 30
0
 def test_from_supporting_app_internal_component(self):
     view = findview('news:InNlSupporting')
     assert 'nlsupporting.components.news.views.InNlSupporting' in str(view)
Ejemplo n.º 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
Ejemplo n.º 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)