def test_buildForm(self):
        """Test that we can build a form by passing it a function and params.
        """
        myFunctionId = 'I T B Fatality Function Configurable'
        myFunctionList = get_plugins(myFunctionId)
        assert len(myFunctionList) == 1
        assert myFunctionList[0].keys()[0] == myFunctionId

        myDialog = FunctionOptionsDialog(None)
        myParameters = {
            'thresholds': [1.0],
            'postprocessors': {
                'Gender': {'on': True},
                'Age': {
                    'on': True,
                    'params': {
                        'youth_ratio': 0.263,
                        'elder_ratio': 0.078,
                        'adult_ratio': 0.659}}}}

        myDialog.buildForm(myParameters)

        assert myDialog.tabWidget.count() == 2

        myChildren = myDialog.tabWidget.findChildren(QLineEdit)
        assert len(myChildren) == 4
Exemple #2
0
    def testDynamicTranslationFunctionTitle(self):
        """Test for dynamic translations for function title
        """

        plugins_dict = get_plugins()
        myPluginName = 'Volcano Building Impact'
        myMessage = '%s not found in %s' % (myPluginName, str(plugins_dict))
        assert myPluginName in plugins_dict, myMessage
        func = plugins_dict[myPluginName]

        # English
        func_title = get_function_title(func)
        expected_title = 'Be affected'
        msg = 'expected %s but got %s' % (expected_title, func_title)
        assert func_title == expected_title, msg

        # Indonesia
        os.environ['LANG'] = 'id'
        func_title = get_function_title(func)
        expected_title = 'Terkena dampak'
        msg = ('expected %s but got %s, in lang = %s' %
               (expected_title, func_title, os.environ['LANG']))
        assert expected_title == func_title, msg
    def testDynamicTranslationFunctionTitle(self):
        """Test for dynamic translations for function title
        """

        plugins_dict = get_plugins()
        myPluginName = 'Volcano Building Impact'
        myMessage = '%s not found in %s' % (myPluginName, str(plugins_dict))
        assert myPluginName in plugins_dict, myMessage
        func = plugins_dict[myPluginName]

        # English
        func_title = get_function_title(func)
        expected_title = 'Be affected'
        msg = 'expected %s but got %s' % (expected_title, func_title)
        assert func_title == expected_title, msg

        # Indonesia
        os.environ['LANG'] = 'id'
        func_title = get_function_title(func)
        expected_title = 'Terkena dampak'
        msg = ('expected %s but got %s, in lang = %s'
               % (expected_title, func_title, os.environ['LANG']))
        assert expected_title == func_title, msg