Пример #1
0
    def test_on_rad_postprocessing_toggled(self):
        """Test hazard radio button toggle behaviour works"""
        layer = make_polygon_layer()
        defaults = breakdown_defaults()
        dialog = KeywordsDialog(PARENT, IFACE, layer=layer)
        button = dialog.radPostprocessing
        button.setChecked(False)
        button.click()
        message = ('Toggling the postprocessing radio did not add a '
                   'category to the keywords list.')
        self.assertEqual(dialog.get_value_for_key('category'),
                         'postprocessing', message)

        message = ('Toggling the postprocessing radio did not add an '
                   'aggregation attribute to the keywords list.')
        self.assertEqual(dialog.get_value_for_key(defaults['AGGR_ATTR_KEY']),
                         'KAB_NAME', message)

        message = ('Toggling the postprocessing radio did not add a '
                   'female ratio attribute to the keywords list.')

        self.assertEqual(
            dialog.get_value_for_key(defaults['FEM_RATIO_ATTR_KEY']),
            dialog.tr('Use default'), message)

        message = ('Toggling the postprocessing radio did not add a '
                   'female ratio default value to the keywords list.')
        self.assertEqual(
            float(dialog.get_value_for_key(defaults['FEM_RATIO_KEY'])),
            defaults['FEM_RATIO'], message)
Пример #2
0
    def test_on_rad_postprocessing_toggled(self):
        """Test hazard radio button toggle behaviour works"""
        layer = make_polygon_layer()
        defaults = get_defaults()
        dialog = KeywordsDialog(PARENT, IFACE, layer=layer)
        button = dialog.radPostprocessing
        button.setChecked(False)
        button.click()
        message = (
            'Toggling the postprocessing radio did not add a '
            'category to the keywords list.')
        self.assertEqual(dialog.get_value_for_key(
            'category'), 'postprocessing', message)

        message = (
            'Toggling the postprocessing radio did not add an '
            'aggregation attribute to the keywords list.')
        self.assertEqual(dialog.get_value_for_key(
            defaults['AGGR_ATTR_KEY']), 'KAB_NAME', message)

        message = (
            'Toggling the postprocessing radio did not add a '
            'female ratio attribute to the keywords list.')

        self.assertEqual(dialog.get_value_for_key(
            defaults['FEMALE_RATIO_ATTR_KEY']), dialog.global_default_string,
            message)

        message = (
            'Toggling the postprocessing radio did not add a '
            'female ratio default value to the keywords list.')
        self.assertEqual(float(dialog.get_value_for_key(
            defaults['FEMALE_RATIO_KEY'])), defaults['FEMALE_RATIO'], message)
Пример #3
0
    def test_on_radPostprocessing_toggled(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = defaults()
        myDialog = KeywordsDialog(PARENT, IFACE, layer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        # noinspection PyArgumentList
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myMessage = ('Toggling the postprocessing radio did not add a '
                     'category to the keywords list.')
        assert myDialog.get_value_for_key(
            'category') == 'postprocessing', myMessage

        myMessage = ('Toggling the postprocessing radio did not add an '
                     'aggregation attribute to the keywords list.')
        assert myDialog.get_value_for_key(
            myDefaults['AGGR_ATTR_KEY']) == 'KAB_NAME', myMessage

        myMessage = ('Toggling the postprocessing radio did not add a '
                     'female ratio attribute to the keywords list.')

        assert myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_ATTR_KEY']) == myDialog.tr('Use default'), \
            myMessage

        myMessage = ('Toggling the postprocessing radio did not add a '
                     'female ratio default value to the keywords list.')
        assert float(myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_KEY'])) == myDefaults['FEM_RATIO'], myMessage
Пример #4
0
    def test_on_dsb_female_ratio_default_value_changed(self):
        """Test hazard radio button toggle behaviour works"""
        layer = make_polygon_layer()
        defaults = get_defaults()
        dialog = KeywordsDialog(PARENT, IFACE, layer=layer)
        button = dialog.radPostprocessing
        button.setChecked(False)
        button.click()
        female_ratio_box = dialog.cboFemaleRatioAttribute

        # set to Don't use
        index = female_ratio_box.findText(dialog.do_not_use_string)
        message = (dialog.do_not_use_string + ' not found')
        self.assertNotEqual(index, -1, message)
        female_ratio_box.setCurrentIndex(index)

        message = (
            'Toggling the female ratio attribute combo to'
            ' "Don\'t use" did not add it to the keywords list.')
        self.assertEqual(dialog.get_value_for_key(
            defaults['FEMALE_RATIO_ATTR_KEY']), dialog.do_not_use_string,
            message)

        message = (
            'Toggling the female ratio attribute combo to'
            ' "Don\'t use" did not disable dsbFemaleRatioDefault.')
        is_enabled = dialog.dsbFemaleRatioDefault.isEnabled()
        assert not is_enabled, message

        message = (
            'Toggling the female ratio attribute combo to'
            ' "Don\'t use" did not remove the keyword.')
        assert (dialog.get_value_for_key(defaults['FEMALE_RATIO']) is None), \
            message

        # set to TEST_REAL
        index = female_ratio_box.findText('TEST_REAL')
        message = 'TEST_REAL not found'
        assert (index != -1), message
        female_ratio_box.setCurrentIndex(index)

        message = (
            'Toggling the female ratio attribute combo to "TEST_REAL"'
            ' did not add it to the keywords list.')
        assert dialog.get_value_for_key(
            defaults['FEMALE_RATIO_ATTR_KEY']) == 'TEST_REAL', message

        message = (
            'Toggling the female ratio attribute combo to "TEST_REAL"'
            ' did not disable dsbFemaleRatioDefault.')
        is_enabled = dialog.dsbFemaleRatioDefault.isEnabled()
        assert not is_enabled, message

        message = (
            'Toggling the female ratio attribute combo to "TEST_REAL"'
            ' did not remove the keyword.')
        assert (dialog.get_value_for_key(defaults['FEMALE_RATIO']) is
                None), message
Пример #5
0
    def test_on_dsbFemaleRatioDefault_valueChanged(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = defaults()
        myDialog = KeywordsDialog(PARENT, IFACE, layer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        # noinspection PyArgumentList
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myFemaleRatioAttrBox = myDialog.cboFemaleRatioAttribute

        #set to Don't use
        myIndex = myFemaleRatioAttrBox.findText(
            myDialog.tr('Don\'t use'))
        myMessage = (myDialog.tr('Don\'t use') + ' not found')
        assert (myIndex != -1), myMessage
        myFemaleRatioAttrBox.setCurrentIndex(myIndex)

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not add it to the keywords list.')
        assert myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_ATTR_KEY']) == myDialog.tr('Don\'t use'), \
            myMessage

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not disable dsbFemaleRatioDefault.')
        myIsEnabled = myDialog.dsbFemaleRatioDefault.isEnabled()
        assert not myIsEnabled, myMessage

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not remove the keyword.')
        assert (myDialog.get_value_for_key(myDefaults['FEM_RATIO']) is None), \
            myMessage

        #set to TEST_REAL
        myIndex = myFemaleRatioAttrBox.findText('TEST_REAL')
        myMessage = 'TEST_REAL not found'
        assert (myIndex != -1), myMessage
        myFemaleRatioAttrBox.setCurrentIndex(myIndex)

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not add it to the keywords list.')
        assert myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_ATTR_KEY']) == 'TEST_REAL', myMessage

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not disable dsbFemaleRatioDefault.')
        myIsEnabled = myDialog.dsbFemaleRatioDefault.isEnabled()
        assert not myIsEnabled, myMessage

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not remove the keyword.')
        assert (myDialog.get_value_for_key(myDefaults['FEM_RATIO']) is
                None), myMessage
Пример #6
0
    def test_on_dsb_female_ratio_default_value_changed(self):
        """Test hazard radio button toggle behaviour works"""
        layer = make_polygon_layer()
        defaults = breakdown_defaults()
        dialog = KeywordsDialog(PARENT, IFACE, layer=layer)
        button = dialog.radPostprocessing
        button.setChecked(False)
        button.click()
        female_ratio_box = dialog.cboFemaleRatioAttribute

        #set to Don't use
        index = female_ratio_box.findText(dialog.tr('Don\'t use'))
        message = (dialog.tr('Don\'t use') + ' not found')
        self.assertNotEqual(index, -1, message)
        female_ratio_box.setCurrentIndex(index)

        message = ('Toggling the female ratio attribute combo to'
                   ' "Don\'t use" did not add it to the keywords list.')
        self.assertEqual(
            dialog.get_value_for_key(defaults['FEM_RATIO_ATTR_KEY']),
            dialog.tr('Don\'t use'), message)

        message = ('Toggling the female ratio attribute combo to'
                   ' "Don\'t use" did not disable dsbFemaleRatioDefault.')
        is_enabled = dialog.dsbFemaleRatioDefault.isEnabled()
        assert not is_enabled, message

        message = ('Toggling the female ratio attribute combo to'
                   ' "Don\'t use" did not remove the keyword.')
        assert (dialog.get_value_for_key(defaults['FEM_RATIO']) is None), \
            message

        #set to TEST_REAL
        index = female_ratio_box.findText('TEST_REAL')
        message = 'TEST_REAL not found'
        assert (index != -1), message
        female_ratio_box.setCurrentIndex(index)

        message = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                   ' did not add it to the keywords list.')
        assert dialog.get_value_for_key(
            defaults['FEM_RATIO_ATTR_KEY']) == 'TEST_REAL', message

        message = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                   ' did not disable dsbFemaleRatioDefault.')
        is_enabled = dialog.dsbFemaleRatioDefault.isEnabled()
        assert not is_enabled, message

        message = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                   ' did not remove the keyword.')
        assert (dialog.get_value_for_key(defaults['FEM_RATIO']) is
                None), message
Пример #7
0
 def test_get_value_for_key(self):
     """Test get value for key works."""
     make_padang_layer()
     dialog = KeywordsDialog(PARENT, IFACE)
     expected_value = 'hazard'
     value = dialog.get_value_for_key('category')
     self.assertEqual(value, expected_value)
Пример #8
0
 def test_addWarningsForColons(self):
     """Test add entry to list works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.add_list_entry('bar', 'fo:o')
     myResult = myDialog.get_value_for_key('bar')
     myExpectedResult = 'fo.o'
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
     #
     # Check the user gets a message if they put colons in the value
     #
     myExpectedResult = 'Colons are not allowed, replaced with "."'
     myResult = str(myDialog.lblMessage.text())
     myMessage = ('lblMessage error \nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
     #
     # Check the user gets a message if they put colons in the key
     #
     myDialog.add_list_entry('ba:r', 'foo')
     myExpectedResult = 'Colons are not allowed, replaced with "."'
     myResult = str(myDialog.lblMessage.text())
     myMessage = ('lblMessage error \nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
Пример #9
0
 def test_get_value_for_key(self):
     """Test get value for key works"""
     make_padang_layer()
     dialog = KeywordsDialog(PARENT, IFACE)
     expected_value = 'hazard'
     value = dialog.get_value_for_key('category')
     self.assertEqual(value, expected_value)
Пример #10
0
 def test_add_warnings_for_colons(self):
     """Test add entry to list works"""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.add_list_entry('bar', 'fo:o')
     result = dialog.get_value_for_key('bar')
     expected_result = 'fo.o'
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     #print 'Dict', dialog.getKeywords()
     self.assertEqual(result, expected_result, message)
     #
     # Check the user gets a message if they put colons in the value
     #
     expected_result = 'Colons are not allowed, replaced with "."'
     result = str(dialog.lblMessage.text())
     message = ('lblMessage error \nGot: %s\nExpected: %s\n' %
                (result, expected_result))
     #print 'Dict', dialog.getKeywords()
     self.assertEqual(result, expected_result, message)
     #
     # Check the user gets a message if they put colons in the key
     #
     dialog.add_list_entry('ba:r', 'foo')
     expected_result = 'Colons are not allowed, replaced with "."'
     result = str(dialog.lblMessage.text())
     message = ('lblMessage error \nGot: %s\nExpected: %s\n' %
                (result, expected_result))
     #print 'Dict', dialog.getKeywords()
     self.assertEqual(result, expected_result, message)
Пример #11
0
 def test_add_warnings_for_colons(self):
     """Test add entry to list works."""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.add_list_entry('bar', 'fo:o')
     result = dialog.get_value_for_key('bar')
     expected_result = 'fo.o'
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
     #
     # Check the user gets a message if they put colons in the value
     #
     expected_result = 'Colons are not allowed, replaced with "."'
     result = str(dialog.lblMessage.text())
     message = (
         'lblMessage error \nGot: %s\nExpected: %s\n' %
         (result, expected_result))
     self.assertEqual(result, expected_result, message)
     #
     # Check the user gets a message if they put colons in the key
     #
     dialog.add_list_entry('ba:r', 'foo')
     expected_result = 'Colons are not allowed, replaced with "."'
     result = str(dialog.lblMessage.text())
     message = (
         'lblMessage error \nGot: %s\nExpected: %s\n' %
         (result, expected_result))
     self.assertEqual(result, expected_result, message)
Пример #12
0
 def test_on_radHazard_toggled(self):
     """Test hazard radio button toggle behaviour works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myButton = myDialog.radHazard
     myButton.setChecked(False)
     myButton.click()
     myMessage = ('Toggling the hazard radio did not add a category '
                  'to the keywords list.')
     assert myDialog.get_value_for_key('category') == 'hazard', myMessage
Пример #13
0
 def test_set_category(self):
     """Test set category works."""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.set_category('hazard')
     expected_result = 'hazard'
     result = dialog.get_value_for_key('category')
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
Пример #14
0
 def test_getValueForKey(self):
     """Test get value for key works"""
     makePadangLayer()
     myDialog = KeywordsDialog(PARENT, IFACE)
     myExpectedValue = 'hazard'
     myValue = myDialog.get_value_for_key('category')
     myMessage = ('\nExpected key value of %s\nGot %s' %
                  (myExpectedValue, myValue))
     assert myValue == myExpectedValue, myMessage
Пример #15
0
 def test_add_list_entry(self):
     """Test add entry to list works."""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.add_list_entry('bar', 'foo')
     result = dialog.get_value_for_key('bar')
     expected_result = 'foo'
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
Пример #16
0
 def test_add_list_entry(self):
     """Test add entry to list works."""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.add_list_entry('bar', 'foo')
     result = dialog.get_value_for_key('bar')
     expected_result = 'foo'
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
Пример #17
0
 def test_on_radHazard_toggled(self):
     """Test hazard radio button toggle behaviour works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myButton = myDialog.radHazard
     myButton.setChecked(False)
     myButton.click()
     myMessage = ('Toggling the hazard radio did not add a category '
                  'to the keywords list.')
     assert myDialog.get_value_for_key('category') == 'hazard', myMessage
Пример #18
0
 def test_set_category(self):
     """Test set category works."""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.set_category('hazard')
     expected_result = 'hazard'
     result = dialog.get_value_for_key('category')
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
Пример #19
0
 def test_on_rad_hazard_toggled(self):
     """Test hazard radio button toggle behaviour works"""
     dialog = KeywordsDialog(PARENT, IFACE)
     button = dialog.radHazard
     button.setChecked(False)
     button.click()
     message = ('Toggling the hazard radio did not add a category '
                'to the keywords list.')
     self.assertEqual(dialog.get_value_for_key('category'), 'hazard',
                      message)
Пример #20
0
 def test_on_radHazard_toggled(self):
     """Test hazard radio button toggle behaviour works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myButton = myDialog.radHazard
     myButton.setChecked(False)
     # noinspection PyArgumentList
     QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
     myMessage = ('Toggling the hazard radio did not add a category '
                  'to the keywords list.')
     assert myDialog.get_value_for_key('category') == 'hazard', myMessage
Пример #21
0
 def test_setCategory(self):
     """Test set category works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.set_category('hazard')
     myExpectedResult = 'hazard'
     myResult = myDialog.get_value_for_key('category')
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
Пример #22
0
    def Xtest_on_radExposure_toggled(self):
        """Test exposure radio button toggle behaviour works"""

        # Cannot get this test to work, but it works fine in the safe_qgis
        myDialog = KeywordsDialog(PARENT, IFACE)
        myButton = myDialog.radExposure
        myButton.setChecked(False)
        myButton.click()
        myMessage = ('Toggling the exposure radio did not add a category '
                     'to the keywords list.')
        assert myDialog.get_value_for_key('category') == 'exposure', myMessage
Пример #23
0
    def Xtest_on_radExposure_toggled(self):
        """Test exposure radio button toggle behaviour works"""

        # Cannot get this test to work, but it works fine in the safe_qgis
        myDialog = KeywordsDialog(PARENT, IFACE)
        myButton = myDialog.radExposure
        myButton.setChecked(False)
        myButton.click()
        myMessage = ('Toggling the exposure radio did not add a category '
                     'to the keywords list.')
        assert myDialog.get_value_for_key('category') == 'exposure', myMessage
Пример #24
0
 def test_addListEntry(self):
     """Test add entry to list works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.add_list_entry('bar', 'foo')
     myResult = myDialog.get_value_for_key('bar')
     myExpectedResult = 'foo'
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
Пример #25
0
 def test_on_pbn_add_to_list1_clicked(self):
     """Test adding an item to the list using predefined form works"""
     dialog = KeywordsDialog(PARENT, IFACE, layer=None)
     dialog.reset(False)
     dialog.radPredefined.setChecked(True)
     dialog.cboKeyword.setCurrentIndex(2)
     expected_result = 'foo'
     dialog.lePredefinedValue.setText(expected_result)
     dialog.on_pbnAddToList1_clicked()
     result = dialog.get_value_for_key('datatype')
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
Пример #26
0
 def test_on_rad_hazard_toggled(self):
     """Test hazard radio button toggle behaviour works"""
     dialog = KeywordsDialog(PARENT, IFACE)
     button = dialog.radHazard
     button.setChecked(False)
     button.click()
     message = (
         'Toggling the hazard radio did not add a category '
         'to the keywords list.')
     self.assertEqual(
         dialog.get_value_for_key('category'), 'hazard',
         message)
Пример #27
0
 def test_on_pbn_add_to_list1_clicked(self):
     """Test adding an item to the list using predefined form works"""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.radPredefined.setChecked(True)
     dialog.cboKeyword.setCurrentIndex(2)
     expected_result = 'foo'
     dialog.lePredefinedValue.setText(expected_result)
     dialog.on_pbnAddToList1_clicked()
     result = dialog.get_value_for_key('datatype')
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
Пример #28
0
 def test_on_pbn_add_to_list2_clicked(self):
     """Test adding an item to the list using user defined form works"""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.radUserDefined.setChecked(True)
     dialog.leKey.setText('foo')
     dialog.leValue.setText('bar')
     expected_result = 'bar'
     dialog.lePredefinedValue.setText(expected_result)
     dialog.on_pbnAddToList2_clicked()
     result = dialog.get_value_for_key('foo')
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
Пример #29
0
 def test_on_pbn_add_to_list2_clicked(self):
     """Test adding an item to the list using user defined form works"""
     dialog = KeywordsDialog(PARENT, IFACE)
     dialog.reset(False)
     dialog.radUserDefined.setChecked(True)
     dialog.leKey.setText('foo')
     dialog.leValue.setText('bar')
     expected_result = 'bar'
     dialog.lePredefinedValue.setText(expected_result)
     dialog.on_pbnAddToList2_clicked()
     result = dialog.get_value_for_key('foo')
     message = '\nGot: %s\nExpected: %s\n' % (result, expected_result)
     self.assertEqual(result, expected_result, message)
Пример #30
0
    def test_on_pbnAddToList1_clicked(self):
        """Test adding an item to the list using predefined form works"""
        myDialog = KeywordsDialog(PARENT, IFACE)
        myDialog.reset(False)
        myDialog.radPredefined.setChecked(True)
        myDialog.cboKeyword.setCurrentIndex(2)
        myExpectedResult = 'foo'
        myDialog.lePredefinedValue.setText(myExpectedResult)
        myDialog.on_pbnAddToList1_clicked()
        myResult = myDialog.get_value_for_key('datatype')
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))

        assert myResult == myExpectedResult, myMessage
Пример #31
0
    def test_on_pbnAddToList1_clicked(self):
        """Test adding an item to the list using predefined form works"""
        myDialog = KeywordsDialog(PARENT, IFACE)
        myDialog.reset(False)
        myDialog.radPredefined.setChecked(True)
        myDialog.cboKeyword.setCurrentIndex(2)
        myExpectedResult = 'foo'
        myDialog.lePredefinedValue.setText(myExpectedResult)
        myDialog.on_pbnAddToList1_clicked()
        myResult = myDialog.get_value_for_key('datatype')
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))

        assert myResult == myExpectedResult, myMessage
Пример #32
0
 def test_on_pbnAddToList2_clicked(self):
     """Test adding an item to the list using user defined form works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.radUserDefined.setChecked(True)
     myDialog.leKey.setText('foo')
     myDialog.leValue.setText('bar')
     myExpectedResult = 'bar'
     myDialog.lePredefinedValue.setText(myExpectedResult)
     myDialog.on_pbnAddToList2_clicked()
     myResult = myDialog.get_value_for_key('foo')
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     # print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
Пример #33
0
    def test_on_subcategory_currentindexchanged(self):
        """Test subcategory combo change event works"""
        dialog = KeywordsDialog(PARENT, IFACE)
        button = dialog.radHazard
        button.setChecked(True)
        button = dialog.radExposure
        button.click()
        combo = dialog.cboSubcategory
        combo.setCurrentIndex(1)  # change from 'Not set' to 'structure'
        message = ('Changing the subcategory did not add %s '
                   'to the keywords list' % combo.currentText())
        key = dialog.get_value_for_key('subcategory')

        self.assertTrue(key is not None, message)
        assert key in str(combo.currentText()), message
Пример #34
0
    def test_on_cboSubcategory_currentIndexChanged(self):
        """Test subcategory combo change event works"""
        myDialog = KeywordsDialog(PARENT, IFACE)
        myButton = myDialog.radHazard
        myButton.setChecked(True)
        myButton = myDialog.radExposure
        myButton.click()
        myCombo = myDialog.cboSubcategory
        myCombo.setCurrentIndex(1)  # change from 'Not set' to 'structure'
        myMessage = ('Changing the subcategory did not add '
                     'to the keywords list for %s' % myCombo.currentText())
        myKey = myDialog.get_value_for_key('subcategory')

        assert myKey is not None, myMessage
        assert myKey in str(myCombo.currentText()), myMessage
Пример #35
0
 def test_on_pbnAddToList2_clicked(self):
     """Test adding an item to the list using user defined form works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.radUserDefined.setChecked(True)
     myDialog.leKey.setText('foo')
     myDialog.leValue.setText('bar')
     myExpectedResult = 'bar'
     myDialog.lePredefinedValue.setText(myExpectedResult)
     myDialog.on_pbnAddToList2_clicked()
     myResult = myDialog.get_value_for_key('foo')
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     # print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
Пример #36
0
    def test_on_cboSubcategory_currentIndexChanged(self):
        """Test subcategory combo change event works"""
        myDialog = KeywordsDialog(PARENT, IFACE)
        myButton = myDialog.radHazard
        myButton.setChecked(True)
        myButton = myDialog.radExposure
        myButton.click()
        myCombo = myDialog.cboSubcategory
        myCombo.setCurrentIndex(1)  # change from 'Not set' to 'structure'
        myMessage = ('Changing the subcategory did not add '
                     'to the keywords list for %s' %
                     myCombo.currentText())
        myKey = myDialog.get_value_for_key('subcategory')

        assert myKey is not None, myMessage
        assert myKey in str(myCombo.currentText()), myMessage
Пример #37
0
    def test_on_subcategory_currentindexchanged(self):
        """Test subcategory combo change event works"""
        dialog = KeywordsDialog(PARENT, IFACE)
        button = dialog.radHazard
        button.setChecked(True)
        button = dialog.radExposure
        button.click()
        combo = dialog.cboSubcategory
        combo.setCurrentIndex(1)  # change from 'Not set' to 'structure'
        message = (
            'Changing the subcategory did not add %s to the keywords list' %
            combo.currentText())
        key = dialog.get_value_for_key('subcategory')

        self.assertTrue(key is not None, message)
        assert key in str(combo.currentText()), message
Пример #38
0
    def test_add_keyword_when_press_ok_button(self):
        """Test add keyword when ok button is pressed."""
        #_, path = makePadangLayerClone()
        clone_padang_layer()
        dialog = KeywordsDialog(PARENT, IFACE)

        dialog.radUserDefined.setChecked(True)
        dialog.leKey.setText('foo')
        dialog.leValue.setText('bar')
        ok_button = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok)
        ok_button.click()

        # delete temp file
        # removeTempFile(path)

        expected_result = 'bar'
        result = dialog.get_value_for_key('foo')
        self.assertEqual(result, expected_result)
Пример #39
0
    def test_add_keyword_when_press_ok_button(self):
        """Test add keyword when ok button is pressed."""
        # _, path = makePadangLayerClone()
        clone_padang_layer()
        dialog = KeywordsDialog(PARENT, IFACE)

        dialog.radUserDefined.setChecked(True)
        dialog.leKey.setText('foo')
        dialog.leValue.setText('bar')
        ok_button = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok)
        ok_button.click()

        # delete temp file
        # removeTempFile(path)

        expected_result = 'bar'
        result = dialog.get_value_for_key('foo')
        self.assertEqual(result, expected_result)
Пример #40
0
    def test_on_cboSubcategory_currentIndexChanged(self):
        """Test subcategory combo change event works"""
        myDialog = KeywordsDialog(PARENT, IFACE)
        myButton = myDialog.radHazard
        myButton.setChecked(True)
        myButton = myDialog.radExposure
        # noinspection PyArgumentList
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myCombo = myDialog.cboSubcategory
        # noinspection PyArgumentList
        QTest.mouseClick(myCombo, QtCore.Qt.LeftButton)
        QTest.keyClick(myCombo, QtCore.Qt.Key_Up)
        QTest.keyClick(myCombo, QtCore.Qt.Key_Enter)
        myMessage = ('Changing the subcategory did not add '
                     'to the keywords list for %s' %
                     myCombo.currentText())
        myKey = myDialog.get_value_for_key('subcategory')

        assert myKey is not None, myMessage
        assert myKey in str(myCombo.currentText()), myMessage
Пример #41
0
    def test_addKeywordWhenPressOkButton(self):
        """Test add keyword when ok button is pressed."""
        #_, myFile = makePadangLayerClone()
        makePadangLayerClone()
        myDialog = KeywordsDialog(PARENT, IFACE)

        myDialog.radUserDefined.setChecked(True)
        myDialog.leKey.setText('foo')
        myDialog.leValue.setText('bar')
        okButton = myDialog.buttonBox.button(QtGui.QDialogButtonBox.Ok)
        okButton.click()

        # delete temp file
        # removeTempFile(myFile)

        myExpectedResult = 'bar'
        myResult = myDialog.get_value_for_key('foo')
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))
        assert myExpectedResult == myResult, myMessage
Пример #42
0
    def test_addKeywordWhenPressOkButton(self):
        """Test add keyword when ok button is pressed."""
        #_, myFile = makePadangLayerClone()
        makePadangLayerClone()
        myDialog = KeywordsDialog(PARENT, IFACE)

        myDialog.radUserDefined.setChecked(True)
        myDialog.leKey.setText('foo')
        myDialog.leValue.setText('bar')
        okButton = myDialog.buttonBox.button(QtGui.QDialogButtonBox.Ok)
        okButton.click()

        # delete temp file
        # removeTempFile(myFile)

        myExpectedResult = 'bar'
        myResult = myDialog.get_value_for_key('foo')
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))
        assert myExpectedResult == myResult, myMessage