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)
Exemple #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)
 def get_igac_economic_info(db, **kwargs):
     """
     Query by component: Economic info
     :param kwargs: dict with one of the following key-value param
            plot_t_ids
            parcel_fmi
            parcel_number
            previous_parcel_number
     :return:
     """
     params = QGISLADMQuery._get_parameters(kwargs)
     query = economic_query.get_igac_economic_query(
         names=db.names,
         schema=db.schema,
         plot_t_ids=params[QueryNames.SEARCH_KEY_PLOT_T_IDS],
         parcel_fmi=params[QueryNames.SEARCH_KEY_PARCEL_FMI],
         parcel_number=params[QueryNames.SEARCH_KEY_PARCEL_NUMBER],
         previous_parcel_number=params[
             QueryNames.SEARCH_KEY_PREVIOUS_PARCEL_NUMBER])
     return PGLADMQuery._get_query_results(db, query)