def setUpClass(cls):
        import_processing()
        import_asistente_ladm_col() # Import plugin
        cls.db_gpkg = get_copy_gpkg_conn('test_ladm_col_queries_qpkg')

        # We can't use the restored database connection because the expression functions use the one in the plugin;
        # that's why we have to get the database connection and assign it to the plugin
        cls.plugin = utils.plugins["asistente_ladm_col"]  # Dict of active plugins
        cls.conn_manager = cls.plugin.conn_manager
        cls.conn_manager.set_db_connector_for_source(cls.db_gpkg)

        res, code, msg = cls.db_gpkg.test_connection()
        cls.assertTrue(res, msg)
        cls.assertIsNotNone(cls.db_gpkg.names.T_ID_F, 'Names is None')
        cls.ladm_queries = QGISLADMQuery()

        # Maybe custom expression functions are not register in processing module
        QgsExpression.registerFunction(get_domain_code_from_value)
        QgsExpression.registerFunction(get_domain_value_from_code)

        # Plots to be consulted are defined
        layers = {
            cls.db_gpkg.names.LC_PLOT_T: None
        }
        cls.plugin.app.core.get_layers(cls.db_gpkg, layers, load=True)
        cls.test_plot_t_ids = get_field_values_by_key_values(layers[cls.db_gpkg.names.LC_PLOT_T],
                                                             cls.db_gpkg.names.T_ILI_TID_F,
                                                             ['fc68c492-fad5-4a7b-98a3-6104e84a4ec4'],
                                                             cls.db_gpkg.names.T_ID_F)
コード例 #2
0
    def setUpClass(cls):
        import_processing()
        import_asistente_ladm_col()  # Import plugin
        import_qgis_model_baker()
        cls.db_gpkg = get_copy_gpkg_conn('test_ladm_col_queries_qpkg')

        # We can't use the restored database connection because the expression functions use the one in the plugin;
        # that's why we have to get the database connection and assign it to the plugin
        cls.plugin = utils.plugins[
            "asistente_ladm_col"]  # Dict of active plugins
        cls.conn_manager = cls.plugin.conn_manager
        cls.conn_manager.set_db_connector_for_source(cls.db_gpkg)

        res, code, msg = cls.db_gpkg.test_connection()
        cls.assertTrue(res, msg)
        cls.assertIsNotNone(cls.db_gpkg.names.T_ID_F, 'Names is None')
        cls.ladm_queries = QGISLADMQuery()

        # Maybe custom expression functions are not register in processing module
        QgsExpression.registerFunction(get_domain_code_from_value)
        QgsExpression.registerFunction(get_domain_value_from_code)

        # Standardize query results: id's are removed because it depends on the database test data
        standardize_query_results(expected_result_ladm_basic_query)
        standardize_query_results(expected_result_ladm_economic_query)
        standardize_query_results(expected_result_ladm_legal_query)
        standardize_query_results(expected_result_ladm_physical_query)
        standardize_query_results(
            expected_result_ladm_property_record_card_query)
コード例 #3
0
import nose2

from qgis.core import (QgsVectorLayer, QgsWkbTypes, QgsGeometry)
from qgis.testing import (unittest, start_app)

from asistente_ladm_col.app_interface import AppInterface
from asistente_ladm_col.lib.geometry import GeometryUtils

start_app()  # need to start before asistente_ladm_col.tests.utils

from asistente_ladm_col.tests.utils import (import_processing,
                                            get_test_copy_path, get_pg_conn,
                                            get_gpkg_conn, restore_schema)

import_processing()
import processing


class TestGeometryUtils(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.app = AppInterface()
        cls.geometry = GeometryUtils()

    def test_split_by_selected_boundary(self):
        print('\nINFO: Validation of the definition of selected boundary ...')

        gpkg_path = get_test_copy_path(
            'db/static/gpkg/adjust_boundaries_cases.gpkg')
        self.db_gpkg = get_gpkg_conn('adjust_boundaries_cases_gpkg')
        names = self.db_gpkg.names