Exemplo n.º 1
0
    def test_filtering_of_impact_functions(self):
        """Impact functions are filtered correctly
        """

        # Keywords matching F1 and F3
        haz_keywords1 = dict(category='hazard', subcategory='flood',
                                layertype='raster', unit='m')
        exp_keywords1 = dict(category='exposure', subcategory='population',
                             layertype='raster', datatype='population')

        # Keywords matching F2 and F3
        haz_keywords2 = dict(category='hazard', subcategory='flood',
                             layertype='raster', unit='m')
        exp_keywords2 = dict(category='exposure', subcategory='building')

        # Check correct matching
        P = get_admissible_plugins([haz_keywords1, exp_keywords1])
        msg = 'Expected impact functions F1 and F3 in %s' % str(P.keys())
        assert 'F1' in P and 'F3' in P, msg

        P = get_admissible_plugins([haz_keywords2, exp_keywords2])
        msg = 'Expected impact functions F2 and F3 in %s' % str(P.keys())
        assert 'F2' in P and 'F3' in P, msg

        # Check empty call returns all
        P = get_admissible_plugins([])
        msg = ('Expected at least impact functions F1, F2 and F3 in %s'
               % str(P.keys()))
        assert 'F1' in P and 'F2' in P and 'F3' in P, msg
Exemplo n.º 2
0
    def test_filtering_of_impact_functions(self):
        """Impact functions are filtered correctly
        """

        # Keywords matching F1 and F3
        haz_keywords1 = dict(category='test_cat1',
                             subcategory='flood',
                             layertype='raster',
                             unit='m')
        exp_keywords1 = dict(category='test_cat2',
                             subcategory='population',
                             layertype='raster',
                             datatype='population')

        # Keywords matching F2 and F3
        haz_keywords2 = dict(category='test_cat1',
                             subcategory='flood',
                             layertype='raster',
                             unit='m')
        exp_keywords2 = dict(category='test_cat2', subcategory='building')

        # Check correct matching of keyword set 1
        P = get_admissible_plugins([haz_keywords1, exp_keywords1])
        msg = 'Expected impact functions F1 and F3 in %s' % str(P.keys())
        assert 'F1' in P and 'F3' in P, msg

        # Check correctness of title attribute
        assert get_function_title(P['F1']) == 'Title for F1'
        assert get_function_title(P['F3']) == 'F3'

        # Check correct matching of keyword set 2
        P = get_admissible_plugins([haz_keywords2, exp_keywords2])
        msg = 'Expected impact functions F2 and F3 in %s' % str(P.keys())
        assert 'F2' in P and 'F3' in P, msg

        # Check correctness of title attribute
        assert get_function_title(P['F2']) == 'Title for F2'
        assert get_function_title(P['F3']) == 'F3'

        # Check empty call returns all
        P = get_admissible_plugins([])
        msg = ('Expected at least impact functions F1, F2 and F3 in %s' %
               str(P.keys()))
        assert 'F1' in P and 'F2' in P and 'F3' in P, msg
Exemplo n.º 3
0
    def test_filtering_of_impact_functions(self):
        """Impact functions are filtered correctly
        """

        # Keywords matching F1 and F3
        haz_keywords1 = dict(category='test_cat1', subcategory='flood',
                             layertype='raster', unit='m')
        exp_keywords1 = dict(category='test_cat2', subcategory='population',
                             layertype='raster', datatype='population')

        # Keywords matching F2 and F3
        haz_keywords2 = dict(category='test_cat1', subcategory='flood',
                             layertype='raster', unit='m')
        exp_keywords2 = dict(category='test_cat2', subcategory='building')

        # Check correct matching of keyword set 1
        P = get_admissible_plugins([haz_keywords1, exp_keywords1])
        msg = 'Expected impact functions F1 and F3 in %s' % str(P.keys())
        assert 'F1' in P and 'F3' in P, msg

        # Check correctness of title attribute
        assert get_function_title(P['F1']) == 'Title for F1'
        assert get_function_title(P['F3']) == 'F3'

        # Check correct matching of keyword set 2
        P = get_admissible_plugins([haz_keywords2, exp_keywords2])
        msg = 'Expected impact functions F2 and F3 in %s' % str(P.keys())
        assert 'F2' in P and 'F3' in P, msg

        # Check correctness of title attribute
        assert get_function_title(P['F2']) == 'Title for F2'
        assert get_function_title(P['F3']) == 'F3'

        # Check empty call returns all
        P = get_admissible_plugins([])
        msg = ('Expected at least impact functions F1, F2 and F3 in %s'
               % str(P.keys()))
        assert 'F1' in P and 'F2' in P and 'F3' in P, msg