Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge MetaSearch into QGIS core #1711

Closed
wants to merge 9 commits into from
Closed

merge MetaSearch into QGIS core #1711

wants to merge 9 commits into from

Conversation

tomkralidis
Copy link
Contributor

cc @kalxas @rduivenvoorde @alexbruy @timlinux @jef-n

This PR officially moves MetaSearch into QGIS core as per geopython/MetaSearch#62. Notes:

@pcav
Copy link
Member

pcav commented Dec 1, 2014

@tomkralidis : any test?

@tomkralidis
Copy link
Contributor Author

@pcav no tests. There are smoke tests in pavement.py which check that the default CSWs are working, but that's about it. Are there any example of how to make tests for Python plugins? Having said this, most functionality tests are covered upstream in OWSLib. MetaSearch is simply the GUI + handling.

@m-kuhn
Copy link
Member

m-kuhn commented Dec 1, 2014

@tomkralidis There are a lot of python tests available here:
https://github.com/qgis/QGIS/tree/master/tests/src/python

Either you write one that does not require a running QGIS or I guess initQgis() plus the following code could get you started:
http://gis.stackexchange.com/questions/68599/can-one-expose-variables-to-the-python-console-from-a-plugin-in-qgis/68607#68607

@m-kuhn
Copy link
Member

m-kuhn commented Dec 3, 2014

When you have written some tests, please also rebase to fix the currently failing composerhtml test

@strk
Copy link
Contributor

strk commented Dec 11, 2014

current master is failing on travis anyway, better not rebase now... (might need a ticket against the "testsuite" component)

@tomkralidis
Copy link
Contributor Author

@m-kuhn: trying with qgis.utils.plugins['MetaSearch'] works great from the Python console of QGIS itself, but yields an empty dict from a testing scenario. Do I have to call something to populate/load plugins for this to work?

I then tried using the another approach, see https://github.com/geopython/QGIS/blob/MetaSearch-merge-core/tests/src/python/test_qgsmetasearch.py#L38-L44

Running the tests locally fail (see below). I'm unsure as to whether this is failing because how the plugin is loaded in test_qgsmetasearch.py, or something else. This also appears to be new ground (testing a core Python plugin from within the QGIS test setup).

tkralidi@tkralidi-VirtualBox:~/QGIS/QGIS/build$ xvfb-run ctest -V -R MetaSearch
UpdateCTestConfiguration  from :/home/tkralidi/QGIS/QGIS/build/DartConfiguration.tcl
Parse Config file:/home/tkralidi/QGIS/QGIS/build/DartConfiguration.tcl
 Add coverage exclude regular expressions.
 Add coverage exclude: /CMakeFiles/CMakeTmp/
 Add coverage exclude: .*/Testing/Utilities/.*
 Add coverage exclude: .*/Utilities/.*
 Add coverage exclude: .*/Code/Wrappers/SWIG/otbApplicationPYTHON_wrap.*
 Add coverage exclude: .*/Code/Wrappers/SWIG/otbApplicationJAVA_wrap.*
UpdateCTestConfiguration  from :/home/tkralidi/QGIS/QGIS/build/DartConfiguration.tcl
Parse Config file:/home/tkralidi/QGIS/QGIS/build/DartConfiguration.tcl
Test project /home/tkralidi/QGIS/QGIS/build
Constructing a list of tests
Done constructing a list of tests
Checking test dependency graph...
Checking test dependency graph end
test 118
    Start 118: PyQgsMetaSearch

118: Test command: /usr/bin/cmake "-P" "/home/tkralidi/QGIS/QGIS/build/tests/src/python/PyQgsMetaSearch.cmake"
118: Test timeout computed to be: 1500
118: -- Running /usr/bin/python /home/tkralidi/QGIS/QGIS/tests/src/python/test_qgsmetasearch.py 
118: LD_LIBRARY_PATH:NOTFOUND:/home/tkralidi/QGIS/QGIS/build/output/lib:
118: PYTHONPATH:/home/tkralidi/QGIS/QGIS/build/output/python/:
118: Running from build directory!
118: - source directory: /home/tkralidi/QGIS/QGIS
118: - output directory of the build: /home/tkralidi/QGIS/QGIS/build/output
118: !!! prefix path was requested, but it is not valid - we do not run from installed path !!!
118: QGraphicsScene::addItem: item has already been added to this scene
118: E
118: ======================================================================
118: ERROR: test_plugin_metadata (__main__.TestQgsMetaSearch)
118: ----------------------------------------------------------------------
118: Traceback (most recent call last):
118:   File "/home/tkralidi/QGIS/QGIS/tests/src/python/test_qgsmetasearch.py", line 43, in setUp
118:     self.plugin = MetaSearch.classFactory(IFACE)
118:   File "/home/tkralidi/QGIS/QGIS/build/output/python//plugins/MetaSearch/__init__.py", line 32, in classFactory
118:     return MetaSearchPlugin(iface)
118:   File "/home/tkralidi/QGIS/QGIS/build/output/python//plugins/MetaSearch/plugin.py", line 53, in __init__
118:     locale_name = QSettings().value("locale/userLocale")[0:2]
118: TypeError: 'QVariant' object has no attribute '__getitem__'
118: 
118: ----------------------------------------------------------------------
118: Ran 1 test in 0.591s
118: 
118: FAILED (errors=1)
118: Application state:
118: QGIS_PREFIX_PATH env var:      /home/tkralidi/QGIS/QGIS/build/output
118: Prefix:        
118: Plugin Path:       /home/tkralidi/QGIS/QGIS/build/output/lib/qgis/plugins
118: Package Data Path: /home/tkralidi/QGIS/QGIS
118: Active Theme Name: 
118: Active Theme Path: :/images/themes//
118: Default Theme Path:    :/images/themes/default/
118: SVG Search Paths:  /home/tkralidi/QGIS/QGIS/images/svg/
118:        /home/tkralidi/.qgis2//svg/
118: User DB Path:  /home/tkralidi/QGIS/QGIS/resources/qgis.db
118: 
118: 
118: CMake Error at PyQgsMetaSearch.cmake:28 (MESSAGE):
118:   1
118: 
118: 
1/1 Test #118: PyQgsMetaSearch ..................***Failed    2.40 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   2.43 sec

The following tests FAILED:
    118 - PyQgsMetaSearch (Failed)
Errors while running CTest

@m-kuhn
Copy link
Member

m-kuhn commented Dec 17, 2014

The test is running on sipapi version 1 instead of 2.
To fix it add a call to import qgis (that does the sip.setapi call internally) before any PyQt imports are made.
http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html

@tomkralidis
Copy link
Contributor Author

No luck on the tests after this fix. As discussed on irc, I'll submit a PR leaving the tests out for future work. Closing this PR and will issue new/fresh/clean PR.

@tomkralidis tomkralidis deleted the MetaSearch-merge-core branch January 4, 2015 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants