Skip to content

Instantly share code, notes, and snippets.

@akbargumbira
Last active August 29, 2015 14:02
Show Gist options
  • Save akbargumbira/3b97a5430700cc171935 to your computer and use it in GitHub Desktop.
Save akbargumbira/3b97a5430700cc171935 to your computer and use it in GitHub Desktop.
Wizard Dialog Test Windows
def test_keywords_creation_wizard(self):
"""Test how the widgets work."""
expected_category_count = 3
expected_categories = ['exposure', 'hazard', 'aggregation']
chosen_category = 'hazard'
expected_subcategory_count = 4
expected_subcategories = ['volcano', 'earthquake', 'flood', 'tsunami']
chosen_subcategory = "tsunami"
expected_unit_count = 3
expected_units = ['wetdry', 'metres_depth', 'feet_depth']
expected_chosen_unit = 'feet_depth'
expected_field_count = 5
expected_fields = ['OBJECTID', 'GRIDCODE', 'Shape_Leng', 'Shape_Area',
'Category']
expected_chosen_field = 'GRIDCODE'
expected_keywords = {
'category': 'hazard',
'subcategory': 'tsunami',
'unit': 'feet_depth',
'field': 'GRIDCODE',
'source': 'some source',
'title': 'some title'
}
layer = clone_shp_layer()
# check the environment first
message = 'Test layer is not readable. Check environment variables.'
self.assertIsNotNone(layer.dataProvider(), message)
# Initialize dialog
# noinspection PyTypeChecker
dialog = WizardDialog(PARENT, IFACE, None, layer)
# step 1 of 7 - select category
count = dialog.lstCategories.count()
message = ('Invalid category count! There should be %d while there '
'were: %d') % (expected_category_count, count)
self.assertEqual(count, expected_category_count, message)
--------------------------------------------------------------------------------------------------------------------------------------
DELETE BEFORE INSTANTIATING DIALOG OK if we delete layer object
--------------------------------------------------------------------------------
def test_keywords_creation_wizard(self):
"""Test how the widgets work."""
expected_category_count = 3
expected_categories = ['exposure', 'hazard', 'aggregation']
chosen_category = 'hazard'
expected_subcategory_count = 4
expected_subcategories = ['volcano', 'earthquake', 'flood', 'tsunami']
chosen_subcategory = "tsunami"
expected_unit_count = 3
expected_units = ['wetdry', 'metres_depth', 'feet_depth']
expected_chosen_unit = 'feet_depth'
expected_field_count = 5
expected_fields = ['OBJECTID', 'GRIDCODE', 'Shape_Leng', 'Shape_Area',
'Category']
expected_chosen_field = 'GRIDCODE'
expected_keywords = {
'category': 'hazard',
'subcategory': 'tsunami',
'unit': 'feet_depth',
'field': 'GRIDCODE',
'source': 'some source',
'title': 'some title'
}
layer = clone_shp_layer()
layer_path = layer.source()
del layer
remove_temp_file(layer_path)
# check the environment first
message = 'Test layer is not readable. Check environment variables.'
self.assertIsNotNone(layer.dataProvider(), message)
# Initialize dialog
# noinspection PyTypeChecker
dialog = WizardDialog(PARENT, IFACE, None, layer)
# step 1 of 7 - select category
count = dialog.lstCategories.count()
message = ('Invalid category count! There should be %d while there '
'were: %d') % (expected_category_count, count)
self.assertEqual(count, expected_category_count, message)
--------------------------------------------------------------------------------------------------------------------------------------
DELETE AFTER INSTANTIATING DIALOG Ok if we delete layer and dialog.layer object
--------------------------------------------------------------------------------
def test_keywords_creation_wizard(self):
"""Test how the widgets work."""
expected_category_count = 3
expected_categories = ['exposure', 'hazard', 'aggregation']
chosen_category = 'hazard'
expected_subcategory_count = 4
expected_subcategories = ['volcano', 'earthquake', 'flood', 'tsunami']
chosen_subcategory = "tsunami"
expected_unit_count = 3
expected_units = ['wetdry', 'metres_depth', 'feet_depth']
expected_chosen_unit = 'feet_depth'
expected_field_count = 5
expected_fields = ['OBJECTID', 'GRIDCODE', 'Shape_Leng', 'Shape_Area',
'Category']
expected_chosen_field = 'GRIDCODE'
expected_keywords = {
'category': 'hazard',
'subcategory': 'tsunami',
'unit': 'feet_depth',
'field': 'GRIDCODE',
'source': 'some source',
'title': 'some title'
}
layer = clone_shp_layer()
# check the environment first
message = 'Test layer is not readable. Check environment variables.'
self.assertIsNotNone(layer.dataProvider(), message)
# Initialize dialog
# noinspection PyTypeChecker
dialog = WizardDialog(PARENT, IFACE, None, layer)
layer_path = layer.source()
del layer
del dialog.layer
remove_temp_file(layer_path)
# step 1 of 7 - select category
count = dialog.lstCategories.count()
message = ('Invalid category count! There should be %d while there '
'were: %d') % (expected_category_count, count)
self.assertEqual(count, expected_category_count, message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment