Beispiel #1
0
    def test_basic_requirements_check(self):
        """Basic plugin requirements check
        """
        requirelines = requirements_collect(BasicFunction)
        params = {'category': 'exposure'}
        for line in requirelines:
            check = requirement_check(params, line)
            assert check == False

        line = "unit='mmi'"
        params = {'category': 'exposure'}
        msg = 'Malformed statement (logged)'
        assert requirement_check(params, line) == False, msg
Beispiel #2
0
    def test_basic_requirements_check(self):
        """Basic plugin requirements check
        """
        requirelines = requirements_collect(BasicFunction)
        params = {'category': 'exposure'}
        for line in requirelines:
            check = requirement_check(params, line)
            assert check == False

        line = "unit='mmi'"
        params = {'category': 'exposure'}
        msg = 'Malformed statement (logged)'
        assert requirement_check(params, line) == False, msg
Beispiel #3
0
    def test_requirements_check(self):
        """Plugins are correctly filtered based on requirements"""

        plugin_list = get_plugins('BasicFunction')
        assert(len(plugin_list) == 1)

        requirements = requirements_collect(plugin_list[0].values()[0])
        msg = 'Requirements are %s' % requirements
        assert(len(requirements) == 1), msg
        for req_str in requirements:
            msg = 'Should eval to True'
            assert(requirement_check({'category': 'hazard'},
                                     req_str) is True), msg
            msg = 'Should eval to False'
            assert(requirement_check({'broke': 'broke'},
                                     req_str) is False), msg

        try:
            plugin_list = get_plugins('NotRegistered')
        except AssertionError:
            pass
        else:
            msg = 'Search should fail'
            raise Exception(msg)
Beispiel #4
0
    def test_requirements_check(self):
        """Plugins are correctly filtered based on requirements"""

        plugin_list = get_plugins('BasicFunction')
        assert (len(plugin_list) == 1)

        requirements = requirements_collect(plugin_list[0].values()[0])
        msg = 'Requirements are %s' % requirements
        assert (len(requirements) == 1), msg
        for req_str in requirements:
            msg = 'Should eval to True'
            assert (requirement_check({'category': 'hazard'}, req_str) is
                    True), msg
            msg = 'Should eval to False'
            assert (requirement_check({'broke': 'broke'}, req_str) is
                    False), msg

        try:
            plugin_list = get_plugins('NotRegistered')
        except AssertionError:
            pass
        else:
            msg = 'Search should fail'
            raise Exception(msg)
Beispiel #5
0
    def test_get_plugins(self):
        """Plugins can be collected
        """

        plugin_list = get_plugins()
        assert(len(plugin_list) > 0)

        # Check that every plugin has a requires line
        for plugin in plugin_list.values():
            requirements = requirements_collect(plugin)
            msg = 'There were no requirements in plugin %s' % plugin
            assert(len(requirements) > 0), msg

            for req_str in requirements:
                msg = 'All plugins should return True or False'
                assert(requirement_check({'category': 'hazard',
                                          'subcategory': 'earthquake',
                                          'layerType': 'raster'},
                                         req_str) in [True, False]), msg
Beispiel #6
0
    def test_get_plugins(self):
        """Plugins can be collected
        """

        plugin_list = get_plugins()
        assert (len(plugin_list) > 0)

        # Check that every plugin has a requires line
        for plugin in plugin_list.values():
            requirements = requirements_collect(plugin)
            msg = 'There were no requirements in plugin %s' % plugin
            assert (len(requirements) > 0), msg

            for req_str in requirements:
                msg = 'All plugins should return True or False'
                assert (requirement_check(
                    {
                        'category': 'hazard',
                        'subcategory': 'earthquake',
                        'layerType': 'raster'
                    }, req_str) in [True, False]), msg
Beispiel #7
0
 def test_keywords_error(self):
     """ Handling of reserved python keywords """
     line = "unit=='mmi'"
     params = {'class': 'myclass'}
     msg = 'Reserved keyword in statement (logged)'
     assert requirement_check(params, line) == False, msg
Beispiel #8
0
 def test_keywords_error(self):
     """ Handling of reserved python keywords """
     line = "unit=='mmi'"
     params = {'class': 'myclass'}
     msg = 'Reserved keyword in statement (logged)'
     assert requirement_check(params, line) == False, msg