svir.test package

Submodules

svir.test.qgis_interface module

QGIS plugin implementation.

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Note

This source code was copied from the ‘postgis viewer’ application with original authors: Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org Copyright (c) 2014 Tim Sutton, tim@linfiniti.com

class svir.test.qgis_interface.QgisInterface(canvas)[source]

Bases: PyQt4.QtCore.QObject

Class to expose QGIS objects and functions to plugins.

This class is here for enabling us to run unit tests only, so most methods are simply stubs.

activeLayer()[source]

Get pointer to the active layer (layer selected in the legend).

addDockWidget(area, dock_widget)[source]

Add a dock widget to the main window.

Parameters:
  • area – Where in the ui the dock should be placed.
  • dock_widget (QDockWidget) – A dock widget to add to the UI.
addLayer(layer)[source]

Handle a layer being added to the registry so it shows up in canvas.

Parameters:layer – list<QgsMapLayer> list of map layers that were added
addLayers(layers)[source]

Handle layers being added to the registry so they show up in canvas.

Parameters:layers – list<QgsMapLayer> list of map layers that were added

Note

The QgsInterface api does not include this method, it is added here as a helper to facilitate testing.

addRasterLayer(path, base_name)[source]

Add a raster layer given a raster layer file name

Parameters:
  • path (str) – Path to layer.
  • base_name (str) – Base name for layer.
addToolBar(name)[source]

Add toolbar with specified name.

Parameters:name (str) – Name for the toolbar.
addToolBarIcon(action)[source]

Add an icon to the plugins toolbar.

Parameters:action (QAction) – Action to add to the toolbar.
addVectorLayer(path, base_name, provider_key)[source]

Add a vector layer.

Parameters:
  • path (str) – Path to layer.
  • base_name (str) – Base name for layer.
  • provider_key (str) – Provider key e.g. ‘ogr’
currentLayerChanged
legendInterface()[source]

Get the legend.

mainWindow()[source]

Return a pointer to the main window.

In case of QGIS it returns an instance of QgisApp.

mapCanvas()[source]

Return a pointer to the map canvas.

messageBar()[source]

Get the message bar.

newProject()[source]

Create new project.

removeAllLayers()[source]

Remove layers from the canvas before they get deleted.

removeToolBarIcon(action)[source]

Remove an action (icon) from the plugin toolbar.

Parameters:action (QAction) – Action to add to the toolbar.
setActiveLayer(layer)[source]
zoomFull()[source]

Zoom to the map full extent.

zoomToActiveLayer()[source]

Zoom to extent of active layer.

zoomToNext()[source]

Zoom to next view extent.

zoomToPrevious()[source]

Zoom to previous view extent.

svir.test.test_attribute_selection_dialog module

class svir.test.test_attribute_selection_dialog.AttributeSelectionDialogTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test dialog works.

setUp()[source]

Runs before each test.

tearDown()[source]

Runs after each test.

test_dialog_cancel()[source]

Test we can click cancel.

test_dialog_ok()[source]

Test we can click OK.

svir.test.test_calculate_indices module

class svir.test.test_calculate_indices.CalculateCompositeVariableTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_average()[source]
test_calculate_svi()[source]
test_custom_operator()[source]
test_geometric_mean_negative_argument()[source]
test_geometric_mean_positive_argument()[source]
test_simple_multiplication()[source]
test_simple_sum()[source]
test_weighted_multiplication()[source]
test_weighted_sum()[source]
svir.test.test_calculate_indices.calculate_education_node(proj_def, operator, layer)[source]

Use the calculate_node function to compute the ‘Education’ node using the given project definition and operator. The layer is updated as a side effect.

svir.test.test_calculate_indices.write_output(res_layer, data_dir_name, res_layer_name)[source]

svir.test.test_import_loss_from_csv module

class svir.test.test_import_loss_from_csv.ImportLossFromCsvTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_import_loss_from_csv_exported_by_oqengine()[source]
test_import_loss_from_dummy_csv()[source]

svir.test.test_init module

Tests QGIS plugin init.

class svir.test.test_init.TestInit(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test that the plugin init is usable for QGIS.

Based heavily on the validator class by Alessandro Passoti available here:

http://github.com/qgis/qgis-django/blob/master/qgis-app/
plugins/validator.py
test_read_init()[source]

Test that the plugin __init__ will validate on plugins.qgis.org.

svir.test.test_irmt module

class svir.test.test_irmt.IrmtTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test IRMT works.

setUp()[source]

Runs before each test.

tearDown()[source]

Runs after each test.

test_icon_png()[source]

Test we can click OK.

test_toggle_active_actions()[source]

svir.test.test_loss_aggreagation module

class svir.test.test_loss_aggreagation.AggregateLossByZoneTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_aggregate_using_geometries()[source]
test_aggregate_using_zone_id()[source]
test_purge_empty_zones()[source]

svir.test.test_metadata_utilities module

InaSAFE Disaster risk assessment tool developed by AusAid - Exception Classes.

Custom exception classes for the IS application.

Contact : ole.moller.nielsen@gmail.com

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

class svir.test.test_metadata_utilities.TestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_generate_iso_metadata()[source]
test_valid_iso_xml()[source]

svir.test.test_process_layer module

class svir.test.test_process_layer.AddAttributesTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_add_attributes()[source]
test_find_attribute_id()[source]
class svir.test.test_process_layer.CheckProjectionsTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_different_projections()[source]
test_same_projections()[source]
class svir.test.test_process_layer.CompareLayerContentTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_same_content_case_first_layer_has_more_features()[source]
test_same_content_case_layers_are_completely_different()[source]
test_same_content_case_layers_are_equal()[source]
test_same_content_case_second_layer_has_more_features()[source]

svir.test.test_qgis_environment module

Tests for QGIS functionality.

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

class svir.test.test_qgis_environment.QGISTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test the QGIS Environment

test_projection()[source]

Test that QGIS properly parses a wkt string.

test_qgis_environment()[source]

QGIS environment has the expected providers

svir.test.test_transformations module

class svir.test.test_transformations.Log10TestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_log10_all_positive_values()[source]
test_log10_incrementing_by_one_case_no_zeros_found()[source]
test_log10_incrementing_by_one_case_zeros_found()[source]
test_log10_with_negative_values()[source]
test_log10_with_zeros_unchanged()[source]
class svir.test.test_transformations.MinMaxTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_min_max_direct()[source]
test_min_max_inverse()[source]
class svir.test.test_transformations.MissingValuesTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_transform_with_missing_values()[source]
class svir.test.test_transformations.QuadraticTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_quadratic_direct_decreasing()[source]
test_quadratic_direct_increasing()[source]
test_quadratic_inverse_decreasing()[source]
test_quadratic_inverse_increasing()[source]
class svir.test.test_transformations.RankTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_rank_direct_average()[source]
test_rank_direct_dense()[source]
test_rank_direct_max()[source]
test_rank_direct_min()[source]
test_rank_direct_ordinal()[source]
test_rank_inverse_average()[source]
test_rank_inverse_dense()[source]
test_rank_inverse_max()[source]
test_rank_inverse_min()[source]
test_rank_inverse_ordinal()[source]
class svir.test.test_transformations.SigmoidTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_sigmoid_direct()[source]
test_sigmoid_inverse()[source]
test_sigmoid_inverse_zero_division()[source]
class svir.test.test_transformations.ZScoreTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_z_score_direct()[source]
test_z_score_inverse()[source]

svir.test.test_translations module

Safe Translations Test.

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

class svir.test.test_translations.SafeTranslationsTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test translations work.

setUp()[source]

Runs before each test.

tearDown()[source]

Runs after each test.

test_qgis_translations()[source]

Test that translations work.

svir.test.utilities module

Common functionality used by regression tests.

svir.test.utilities.get_qgis_app()[source]

Start one QGIS application to test against.

Returns:Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None.
Return type:(QgsApplication, CANVAS, IFACE, PARENT)

If QGIS is already running the handle to that app will be returned.

Module contents