本文整理汇总了Python中safe_qgis.tools.keywords_dialog.KeywordsDialog.get_value_for_key方法的典型用法代码示例。如果您正苦于以下问题:Python KeywordsDialog.get_value_for_key方法的具体用法?Python KeywordsDialog.get_value_for_key怎么用?Python KeywordsDialog.get_value_for_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe_qgis.tools.keywords_dialog.KeywordsDialog
的用法示例。
在下文中一共展示了KeywordsDialog.get_value_for_key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_on_rad_postprocessing_toggled
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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)
示例2: test_on_radPostprocessing_toggled
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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
示例3: test_on_dsb_female_ratio_default_value_changed
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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
示例4: test_on_dsbFemaleRatioDefault_valueChanged
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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
示例5: test_add_warnings_for_colons
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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)
示例6: test_get_value_for_key
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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)
示例7: test_addWarningsForColons
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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
示例8: test_add_list_entry
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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)
示例9: test_getValueForKey
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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
示例10: test_on_radHazard_toggled
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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
示例11: test_set_category
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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)
示例12: test_on_radHazard_toggled
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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
示例13: test_setCategory
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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
示例14: test_addListEntry
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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
示例15: Xtest_on_radExposure_toggled
# 需要导入模块: from safe_qgis.tools.keywords_dialog import KeywordsDialog [as 别名]
# 或者: from safe_qgis.tools.keywords_dialog.KeywordsDialog import get_value_for_key [as 别名]
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