Пример #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)