def test_parse_requirement(self):
        """Test parse requirements of a function to dictionary."""
        myRequirement = requirements_collect(F4)[0]
        parsed_req = parse_single_requirement(myRequirement)
        expected_req = {'category': 'hazard',
                        'subcategory': ['flood', 'tsunami']}
        myMessage = 'Get %s should be % s' % (parsed_req, expected_req)
        assert parsed_req == expected_req, myMessage

        myRequirement = requirements_collect(F4)[1]
        parsed_req = parse_single_requirement(myRequirement)
        expected_req = {'category': 'exposure',
                        'subcategory': ['building', 'structure'],
                        'layertype': 'vector'}
        myMessage = 'Get %s should be % s' % (parsed_req, expected_req)
        assert parsed_req == expected_req, myMessage
 def test_basic_plugin_requirements_met(self):
     """Basic plugin requirements met
     """
     requirelines = requirements_collect(BasicFunction)
     valid_return = ['category=="test_cat1"', 'unit=="MMI"']
     for ret1, ret2 in zip(valid_return, requirelines):
         assert ret1 == ret2, "Error in requirements extraction"
Beispiel #3
0
 def test_basic_plugin_requirements_met(self):
     """Basic plugin requirements met
     """
     requirelines = requirements_collect(BasicFunction)
     valid_return = ['category=="test_cat1"', 'unit=="MMI"']
     for ret1, ret2 in zip(valid_return, requirelines):
         assert ret1 == ret2, "Error in requirements extraction"
    def test_basic_plugin_requirements(self):
        """Basic plugin requirements collection
        """
        requirelines = requirements_collect(BasicFunction)
        params = {'category': 'test_cat1', 'unit': 'MMI'}
        assert requirements_met(requirelines, params)

        params = {'category': 'test_cat2', 'unit': 'mmi2'}
        assert not requirements_met(requirelines, params)
Beispiel #5
0
    def test_basic_plugin_requirements(self):
        """Basic plugin requirements collection
        """
        requirelines = requirements_collect(BasicFunction)
        params = {'category': 'test_cat1', 'unit': 'MMI'}
        assert requirements_met(requirelines, params)

        params = {'category': 'test_cat2', 'unit': 'mmi2'}
        assert not requirements_met(requirelines, params)
    def test_basic_plugin_requirements(self):
        """Basic plugin requirements collection
        """
        requirelines = requirements_collect(BasicFunction)
        params = {'category': 'hazard', 'unit': 'mmi'}
        assert requirements_met(requirelines, params)

        params = {'category': 'exposure', 'unit': 'mmi2'}
        assert requirements_met(requirelines, params, True) == False
Beispiel #7
0
    def test_parse_requirement(self):
        """Test parse requirements of a function to dictionary."""
        myRequirement = requirements_collect(F4)[0]
        parsed_req = parse_single_requirement(myRequirement)
        expected_req = {
            'category': 'hazard',
            'subcategory': ['flood', 'tsunami']
        }
        myMessage = 'Get %s should be % s' % (parsed_req, expected_req)
        assert parsed_req == expected_req, myMessage

        myRequirement = requirements_collect(F4)[1]
        parsed_req = parse_single_requirement(myRequirement)
        expected_req = {
            'category': 'exposure',
            'subcategory': ['building', 'structure'],
            'layertype': 'vector'
        }
        myMessage = 'Get %s should be % s' % (parsed_req, expected_req)
        assert parsed_req == expected_req, myMessage
    def test_basic_requirements_check(self):
        """Basic plugin requirements check
        """
        requirelines = requirements_collect(BasicFunction)
        params = {'category': 'test_cat2'}
        for line in requirelines:
            check = requirement_check(params, line)
            assert not check

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

        line = "unit='MMI'"
        params = {'category': 'test_cat2'}
        msg = 'Malformed statement (logged)'
        assert not requirement_check(params, line), msg
    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 #11
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 #12
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 RuntimeError:
            pass
        else:
            msg = 'Search should fail'
            raise Exception(msg)