def test_build_form_minimum_needs(self):
        """Test that we can build a form by passing it params.
        """
        dialog = FunctionOptionsDialog()

        # Define threshold
        threshold = InputListParameter()
        threshold.name = 'Thresholds [m]'
        threshold.is_required = True
        threshold.element_type = float
        threshold.expected_type = list
        threshold.ordering = InputListParameter.AscendingOrder
        threshold.minimum_item_count = 1
        threshold.maximum_item_count = 3
        threshold.value = [1.0]  # default value

        parameters = {
            'thresholds': threshold,
            'postprocessors': OrderedDict([
                ('Gender', default_gender_postprocessor()),
                ('Age', age_postprocessor()),
                ('MinimumNeeds', minimum_needs_selector()),
                ])
        }

        dialog.build_form(parameters)

        assert dialog.tabWidget.count() == 2

        children = dialog.tabWidget.findChildren(QLineEdit)
        assert len(children) == 4
示例#2
0
    def test_build_form_minimum_needs(self):
        """Test that we can build a form by passing it a function and params.
        """
        function_id = 'Flood Evacuation Function Vector Hazard'
        function_list = get_plugins(function_id)
        assert len(function_list) == 1
        assert function_list[0].keys()[0] == function_id

        dialog = FunctionOptionsDialog()
        parameters = {
            'thresholds': [1.0],
            'postprocessors': {
                'Gender': {'on': True},
                'Age': {
                    'on': True,
                    'params': {
                        'youth_ratio': 0.263,
                        'elderly_ratio': 0.078,
                        'adult_ratio': 0.659}}}}

        dialog.build_form(parameters)

        assert dialog.tabWidget.count() == 2

        children = dialog.tabWidget.findChildren(QLineEdit)
        assert len(children) == 4
    def test_build_form(self):
        """Test that we can build a form by passing params.
        """

        dialog = FunctionOptionsDialog()

        # Define rice for minimum needs
        rice = ResourceParameter()
        rice.value = 2.8
        rice.frequency = 'weekly'
        rice.minimum_allowed_value = 1.4
        rice.maximum_allowed_value = 5.6
        rice.name = 'Rice'
        rice.unit.abbreviation = 'kg'
        rice.unit.name = 'kilogram'
        rice.unit.plural = 'kilograms'

        # Define threshold
        threshold = InputListParameter()
        threshold.name = 'Thresholds [m]'
        threshold.is_required = True
        threshold.element_type = float
        threshold.expected_type = list
        threshold.ordering = InputListParameter.AscendingOrder
        threshold.minimum_item_count = 1
        threshold.maximum_item_count = 3
        threshold.value = [1.0]  # default value

        parameter = {
            'thresholds': threshold,
            'postprocessors': OrderedDict([
                ('Gender', default_gender_postprocessor()),
                ('Age', age_postprocessor()),
                ('MinimumNeeds', minimum_needs_selector()),
                ]),
            'minimum needs': [rice]
        }

        dialog.build_form(parameter)

        message = 'There should be %s tabwidget but got %s' % (
            3, dialog.tabWidget.count())
        self.assertEqual(dialog.tabWidget.count(), 3, message)

        children = dialog.tabWidget.findChildren(QLineEdit)
        message = 'There should be %s QLineEdit but got %s' % (
            5, len(children))
        self.assertEqual(len(children), 5, message)
示例#4
0
    def test_build_form(self):
        """Test that we can build a form by passing it a function and params.
        """
        function_id = 'ITB Fatality Function'
        function_list = get_plugins(function_id)
        assert len(function_list) == 1
        assert function_list[0].keys()[0] == function_id

        dialog = FunctionOptionsDialog()

        # Define rice for minimum needs
        rice = ResourceParameter()
        rice.value = 2.8
        rice.frequency = 'weekly'
        rice.minimum_allowed_value = 1.4
        rice.maximum_allowed_value = 5.6
        rice.name = 'Rice'
        rice.unit.abbreviation = 'kg'
        rice.unit.name = 'kilogram'
        rice.unit.plural = 'kilograms'

        parameter = {
            'thresholds': [1.0],
            'postprocessors': {
                'Gender': {'on': True},
                'Age': {
                    'on': True,
                    'params': {
                        'youth_ratio': 0.263,
                        'elderly_ratio': 0.078,
                        'adult_ratio': 0.659
                    }
                }
            },
            'minimum needs': [rice]
        }

        dialog.build_form(parameter)

        message = 'There should be %s tabwidget but got %s' % (
            3, dialog.tabWidget.count())
        self.assertEqual(dialog.tabWidget.count(), 3, message)

        children = dialog.tabWidget.findChildren(QLineEdit)
        message = 'There should be %s QLineEdit but got %s' % (
            5, len(children))
        self.assertEqual(len(children), 5, message)
    def test_build_form_minimum_needs(self):
        """Test that we can build a form by passing it params.
        """
        dialog = FunctionOptionsDialog()
        parameters = {
            'thresholds': [1.0],
            'postprocessors': OrderedDict([
                ('Gender', default_gender_postprocessor()),
                ('Age', age_postprocessor()),
                ('MinimumNeeds', minimum_needs_selector()),
                ])
        }

        dialog.build_form(parameters)

        assert dialog.tabWidget.count() == 2

        children = dialog.tabWidget.findChildren(QLineEdit)
        assert len(children) == 4
    def test_build_form(self):
        """Test that we can build a form by passing params.
        """

        dialog = FunctionOptionsDialog()

        # Define rice for minimum needs
        rice = ResourceParameter()
        rice.value = 2.8
        rice.frequency = 'weekly'
        rice.minimum_allowed_value = 1.4
        rice.maximum_allowed_value = 5.6
        rice.name = 'Rice'
        rice.unit.abbreviation = 'kg'
        rice.unit.name = 'kilogram'
        rice.unit.plural = 'kilograms'

        parameter = {
            'thresholds': [1.0],
            'postprocessors': OrderedDict([
                ('Gender', default_gender_postprocessor()),
                ('Age', age_postprocessor()),
                ('MinimumNeeds', minimum_needs_selector()),
                ]),
            'minimum needs': [rice]
        }

        dialog.build_form(parameter)

        message = 'There should be %s tabwidget but got %s' % (
            3, dialog.tabWidget.count())
        self.assertEqual(dialog.tabWidget.count(), 3, message)

        children = dialog.tabWidget.findChildren(QLineEdit)
        message = 'There should be %s QLineEdit but got %s' % (
            5, len(children))
        self.assertEqual(len(children), 5, message)