コード例 #1
0
    def test_on_radPostprocessing_toggled(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = getDefaults()
        myDialog = KeywordsDialog(PARENT, IFACE, theLayer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myMessage = ('Toggling the postprocessing radio did not add a '
                     'category to the keywords list.')
        assert myDialog.getValueForKey(
            'category') == 'postprocessing', myMessage

        myMessage = ('Toggling the postprocessing radio did not add an '
                     'aggregation attribute to the keywords list.')
        assert myDialog.getValueForKey(
            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.getValueForKey(
            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.getValueForKey(
            myDefaults['FEM_RATIO_KEY'])) == \
               myDefaults['FEM_RATIO'], myMessage
コード例 #2
0
    def test_on_radPostprocessing_toggled(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = getDefaults()
        myDialog = KeywordsDialog(PARENT, IFACE, theLayer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myMessage = ('Toggling the postprocessing radio did not add a '
                     'category to the keywords list.')
        assert myDialog.getValueForKey(
            'category') == 'postprocessing', myMessage

        myMessage = ('Toggling the postprocessing radio did not add an '
                     'aggregation attribute to the keywords list.')
        assert myDialog.getValueForKey(
            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.getValueForKey(
            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.getValueForKey(
            myDefaults['FEM_RATIO_KEY'])) == \
               myDefaults['FEM_RATIO'], myMessage
コード例 #3
0
    def test_on_dsbFemaleRatioDefault_valueChanged(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = getDefaults()
        myDialog = KeywordsDialog(PARENT, IFACE, theLayer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        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.getValueForKey(
            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.getValueForKey(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.getValueForKey(
            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.getValueForKey(myDefaults['FEM_RATIO']) is
                None), myMessage
コード例 #4
0
    def test_on_dsbFemaleRatioDefault_valueChanged(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = getDefaults()
        myDialog = KeywordsDialog(PARENT, IFACE, theLayer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        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.getValueForKey(
            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.getValueForKey(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.getValueForKey(
            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.getValueForKey(myDefaults['FEM_RATIO']) is
                None), myMessage
コード例 #5
0
 def test_addWarningsForColons(self):
     """Test add entry to list works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.addListEntry('bar', 'fo:o')
     myResult = myDialog.getValueForKey('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.addListEntry('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
コード例 #6
0
 def test_addWarningsForColons(self):
     """Test add entry to list works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.addListEntry('bar', 'fo:o')
     myResult = myDialog.getValueForKey('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.addListEntry('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
コード例 #7
0
 def test_getValueForKey(self):
     """Test get value for key works"""
     makePadangLayer()
     myDialog = KeywordsDialog(PARENT, IFACE)
     myExpectedValue = 'hazard'
     myValue = myDialog.getValueForKey('category')
     myMessage = ('\nExpected key value of %s\nGot %s' %
                  (myExpectedValue, myValue))
     assert myValue == myExpectedValue, myMessage
コード例 #8
0
 def test_on_radHazard_toggled(self):
     """Test hazard radio button toggle behaviour works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myButton = myDialog.radHazard
     myButton.setChecked(False)
     QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
     myMessage = ('Toggling the hazard radio did not add a category '
                  'to the keywords list.')
     assert myDialog.getValueForKey('category') == 'hazard', myMessage
コード例 #9
0
 def test_on_radHazard_toggled(self):
     """Test hazard radio button toggle behaviour works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myButton = myDialog.radHazard
     myButton.setChecked(False)
     QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
     myMessage = ('Toggling the hazard radio did not add a category '
                  'to the keywords list.')
     assert myDialog.getValueForKey('category') == 'hazard', myMessage
コード例 #10
0
 def test_getValueForKey(self):
     """Test get value for key works"""
     makePadangLayer()
     myDialog = KeywordsDialog(PARENT, IFACE)
     myExpectedValue = 'hazard'
     myValue = myDialog.getValueForKey('category')
     myMessage = ('\nExpected key value of %s\nGot %s' %
                  (myExpectedValue, myValue))
     assert myValue == myExpectedValue, myMessage
コード例 #11
0
 def test_setCategory(self):
     """Test set category works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.setCategory('hazard')
     myExpectedResult = 'hazard'
     myResult = myDialog.getValueForKey('category')
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
コード例 #12
0
 def test_addListEntry(self):
     """Test add entry to list works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.addListEntry('bar', 'foo')
     myResult = myDialog.getValueForKey('bar')
     myExpectedResult = 'foo'
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
コード例 #13
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)
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myMessage = ('Toggling the exposure radio did not add a category '
                     'to the keywords list.')
        assert myDialog.getValueForKey('category') == 'exposure', myMessage
コード例 #14
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)
        QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
        myMessage = ('Toggling the exposure radio did not add a category '
                     'to the keywords list.')
        assert myDialog.getValueForKey('category') == 'exposure', myMessage
コード例 #15
0
 def test_setCategory(self):
     """Test set category works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.setCategory('hazard')
     myExpectedResult = 'hazard'
     myResult = myDialog.getValueForKey('category')
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
コード例 #16
0
 def test_addListEntry(self):
     """Test add entry to list works"""
     myDialog = KeywordsDialog(PARENT, IFACE)
     myDialog.reset(False)
     myDialog.addListEntry('bar', 'foo')
     myResult = myDialog.getValueForKey('bar')
     myExpectedResult = 'foo'
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     #print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
コード例 #17
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)
        # Work around for commented out line below
        myDialog.on_pbnAddToList1_clicked()
        #QTest.mouseClick(myDialog.pbnAddToList1, QtCore.Qt.LeftButton)
        myResult = myDialog.getValueForKey('datatype')
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))

        assert myResult == myExpectedResult, myMessage
コード例 #18
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)
        # Work around for commented out line below
        myDialog.on_pbnAddToList1_clicked()
        #QTest.mouseClick(myDialog.pbnAddToList1, QtCore.Qt.LeftButton)
        myResult = myDialog.getValueForKey('datatype')
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))

        assert myResult == myExpectedResult, myMessage
コード例 #19
0
 def test_on_pbnAddToList2_clicked(self):
     """Test adding an item to the list using user defened 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)
     # Work around for commented out line below
     myDialog.on_pbnAddToList2_clicked()
     #QTest.mouseClick(myDialog.pbnAddToList2, QtCore.Qt.LeftButton)
     myResult = myDialog.getValueForKey('foo')
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
コード例 #20
0
 def test_on_pbnAddToList2_clicked(self):
     """Test adding an item to the list using user defened 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)
     # Work around for commented out line below
     myDialog.on_pbnAddToList2_clicked()
     #QTest.mouseClick(myDialog.pbnAddToList2, QtCore.Qt.LeftButton)
     myResult = myDialog.getValueForKey('foo')
     myMessage = ('\nGot: %s\nExpected: %s\n' %
                  (myResult, myExpectedResult))
     print 'Dict', myDialog.getKeywords()
     assert myResult == myExpectedResult, myMessage
コード例 #21
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
     QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
     myCombo = myDialog.cboSubcategory
     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.getValueForKey('subcategory')
     assert myKey is not None, myMessage
     assert myKey in str(myCombo.currentText()), myMessage
コード例 #22
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
     QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
     myCombo = myDialog.cboSubcategory
     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.getValueForKey('subcategory')
     assert myKey is not None, myMessage
     assert myKey in str(myCombo.currentText()), myMessage
コード例 #23
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)
        QTest.mouseClick(okButton, QtCore.Qt.LeftButton)

        # delete temp file
        # removeTempFile(myFile)

        myExpectedResult = 'bar'
        myResult = myDialog.getValueForKey('foo')
        myMessage = ('\nGot: %s\nExpected: %s\n' %
                     (myResult, myExpectedResult))
        assert myExpectedResult == myResult, myMessage
コード例 #24
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)
        QTest.mouseClick(okButton, QtCore.Qt.LeftButton)

        # delete temp file
        # removeTempFile(myFile)

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