Skip to content
Snippets Groups Projects
tests.py 1.41 KiB
Newer Older
  • Learn to ignore specific revisions
  • from __future__ import absolute_import
    import six, sys, os, gc, re, collections, site, inspect
    from osgeo import gdal, ogr
    
    from qgis import *
    from qgis.core import *
    from qgis.gui import *
    from PyQt4.QtGui import *
    from PyQt4.QtCore import *
    
    
    
    def test_gui():
        from timeseriesviewer.main import TimeSeriesViewer
    
    Benjamin Jakimow's avatar
    Benjamin Jakimow committed
        from timeseriesviewer import PATH_EXAMPLE_TIMESERIES
    
        S = TimeSeriesViewer(None)
        S.run()
    
    Benjamin Jakimow's avatar
    Benjamin Jakimow committed
    
    
        S.loadTimeSeries(path=PATH_EXAMPLE_TIMESERIES, n_max=10)
    
        pass
    
    def test_component():
    
        pass
    
    if __name__ == '__main__':
        import site, sys
        #add site-packages to sys.path as done by enmapboxplugin.py
    
        from timeseriesviewer import DIR_SITE_PACKAGES
        site.addsitedir(DIR_SITE_PACKAGES)
    
        #prepare QGIS environment
        if sys.platform == 'darwin':
            PATH_QGS = r'/Applications/QGIS.app/Contents/MacOS'
            os.environ['GDAL_DATA'] = r'/usr/local/Cellar/gdal/1.11.3_1/share'
        else:
            # assume OSGeo4W startup
            PATH_QGS = os.environ['QGIS_PREFIX_PATH']
        assert os.path.exists(PATH_QGS)
    
        qgsApp = QgsApplication([], True)
        QApplication.addLibraryPath(r'/Applications/QGIS.app/Contents/PlugIns')
        QApplication.addLibraryPath(r'/Applications/QGIS.app/Contents/PlugIns/qgis')
        qgsApp.setPrefixPath(PATH_QGS, True)
        qgsApp.initQgis()
    
        #run tests
        if True: test_gui()
        if False: test_component()
    
    
        #close QGIS
        qgsApp.exec_()
        qgsApp.exitQgis()