Exemplo n.º 1
0
 def test_that_resolving_warns_about_missing_category_backend_if_no_includes_found(self):
     op = UsesParser()
     category = MockCategory()
     
     op.resolve([category], [])
     
     self.l.check(('root', 'WARNING', "Category '{0}' has no backend specified".format(category.catid)))
Exemplo n.º 2
0
 def test_that_resolve_warns_if_category_linked_to_nonexistant_backend(self):
     backend = 'db'
     category = MockCategory()
     root = _build_tree_with_valid_category_include(backend, category)
     op = UsesParser()
     op.parse(root)
     
     op.resolve([category], {})
     
     self.l.check(('root', 'WARNING', "Category '{0}' has link to nonexistant backend {1}".format(category.catid, backend)))
Exemplo n.º 3
0
 def test_that_resolving_does_not_warn_if_category_missing_backend_but_component_includes_it(self):
     backend = 'db'
     category = MockCategory()
     example_component = Component(categories = [category.catid]) 
     component_name = 'example'
     root = _build_tree_with_valid_component_include(backend, component_name)
     op = UsesParser()
     op.parse(root)        
     
     op.resolve([category], {component_name:example_component}, {backend:MockBackend()})
     
     assert_that(self.l.__str__(), is_("No logging captured"))
Exemplo n.º 4
0
 def test_that_resolve_links_backends_to_categories(self):
     backend_name = 'db'
     category = MockCategory()
     root = _build_tree_with_valid_category_include(backend_name, category)
     op = UsesParser()
     op.parse(root)
     backend = MockBackend()
     
     op.resolve([category], {}, {backend_name:backend})
     
     assert_that(backend.add_category_called, is_(True))
     assert_that(backend.categories, has_item(same_instance(category)))
Exemplo n.º 5
0
 def test_that_resolve_links_categories_to_backend(self):
     backend = 'db'
     category = MockCategory()
     root = _build_tree_with_valid_category_include(backend, category)
     op = UsesParser()
     op.parse(root)
     example_backend = MockBackend()
     
     op.resolve([category], {}, {backend:example_backend})
     
     assert_that(category.set_backend_called, is_(True))
     assert_that(category.backend, is_(same_instance(example_backend)))
Exemplo n.º 6
0
    def test_that_resolving_does_not_warn_if_category_missing_backend_but_include_all_specified(self):
        root = ET.Element('config')
        uses = ET.SubElement(root, 'uses')
        backend = 'db'
        use = ET.SubElement(uses, 'use', {'backend':backend})
        ET.SubElement(use, 'includeall')  
        op = UsesParser()
        category = MockCategory()
        op.parse(root)

        op.resolve([category], [], {backend:MockBackend()})
        
        assert_that(self.l.__str__(), is_("No logging captured"))        
Exemplo n.º 7
0
 def test_that_resolve_warns_if_component_include_is_not_in_components_list(self): 
     component_name = 'nonexistant'
     root = ET.Element('config')
     uses = ET.SubElement(root, 'uses')
     backend = 'db'
     use = ET.SubElement(uses, 'use', {'backend':backend})
     include = ET.SubElement(use, 'include')
     ET.SubElement(include, 'component', {'name':component_name})
     op = UsesParser()  
     op.parse(root)      
     category_name = "don't care"
     op.resolve([MockCategory(category_name)], {})
     
     # TODO We don't care about the second method here.  Create a better matcher than l.check to allow checking for only a subset of the messages 
     self.l.check(('root', 'WARNING', "Component '{0}' is included/excluded for backend {1}, but does not exist".format(component_name, backend)),
                   ('root', 'WARNING', "Category '{0}' has no backend specified".format(category_name)))
Exemplo n.º 8
0
 def test_that_component_level_exclude_overrides_include_all(self):
     category = MockCategory()      
     example_component = Component(categories = [category.catid]) 
     component_name = 'example'
     root = ET.Element('config')
     uses = ET.SubElement(root, 'uses')
     backend = 'db'
     use = ET.SubElement(uses, 'use', {'backend':backend})
     ET.SubElement(use, 'includeall')
     exclude = ET.SubElement(use, 'exclude')
     ET.SubElement(exclude, 'component', {'name':component_name})
     op = UsesParser()  
     op.parse(root)      
     
     op.resolve([category], {component_name:example_component})
     
     self.l.check(('root', 'WARNING', "Category '{0}' has no backend specified".format(category.catid)))