[Qgis-developer] Setting up test with plugin..

Chris Crook ccrook at linz.govt.nz
Thu Apr 11 13:11:05 PDT 2013


Hi Martin

Thanks  for that .  Yes I am testing the just the provider, not sure how I could have automated tests for the plugin dialog.  I had thought that the provider was not available as the first test I wrote failed (below).  However I have now put in a test to load a layer, and that seems to pass.

    def test_001_ProviderDefined( self ):
        registry=QgsProviderRegistry.instance()
        metadata = registry.providerMetadata('delimitedtext')
        assert metadata != None and metadata.description == "Delimited text data provider", "Provider metadata is installed"

Incidentally, I'm also wondering where is the best place to document the provider - ie where to document the url parameters that can be specified, as well as (I guess) where to document usage of the UI.  Any suggestions?  At the moment the only location I know of is your  python cookbook?

Thanks
Chris

-----Original Message-----
From: Martin Dobias [mailto:wonder.sk at gmail.com]
Sent: Thursday, 11 April 2013 8:43 p.m.
To: Chris Crook
Cc: qgis-developer at lists.osgeo.org
Subject: Re: [Qgis-developer] Setting up test with plugin..

Hi Chris

On Thu, Apr 11, 2013 at 9:58 AM, Chris Crook <ccrook at linz.govt.nz> wrote:
> Hi All
>
> I'm fixing a long standing bug in the delimited text plugin (new lines in quoted fields in CSV files), and as part of this I want to build some tests. I'm starting from test_qgsmemoryprovider.py, which seems to be a good starting point, except that before I can run any tests I need to install the plugin.

Are you trying to test the provider or the (GUI) plugin?

The provider can be tested easily by creating a QgsVectorLayer instance with the "delimitedtext" provider string. It is only necessary to initialize QGIS core library which will in turn initialize provider registry (and load all providers). The memory provider test uses a convenience function getQgisTestApp() from utilities.py.

To my knowledge it is not possible to test the plugin:
QgsPluginRegistry is not a part of qgis libraries, it's a class belonging to QGIS executable, so you cannot access it.

Regards
Martin

This message contains information, which is confidential and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.


More information about the Qgis-developer mailing list