Skip to content
Snippets Groups Projects
Commit 5a51e8bd authored by benjamin.jakimow@geo.hu-berlin.de's avatar benjamin.jakimow@geo.hu-berlin.de
Browse files

added & refactored /tests

parent a2f50b96
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ __copyright__ = (
import logging
from PyQt5.QtCore import QObject, pyqtSlot, pyqtSignal
from qgis.core import QgsMapLayerRegistry
from qgis.core import QgsProject
from qgis.gui import QgsMapCanvasLayer
LOGGER = logging.getLogger('QGIS')
......@@ -49,11 +49,11 @@ class QgisInterface(QObject):
# are added.
LOGGER.debug('Initialising canvas...')
# noinspection PyArgumentList
QgsMapLayerRegistry.instance().layersAdded.connect(self.addLayers)
QgsProject.instance().layersAdded.connect(self.addLayers)
# noinspection PyArgumentList
QgsMapLayerRegistry.instance().layerWasAdded.connect(self.addLayer)
QgsProject.instance().layerWasAdded.connect(self.addLayer)
# noinspection PyArgumentList
QgsMapLayerRegistry.instance().removeAll.connect(self.removeAllLayers)
QgsProject.instance().removeAll.connect(self.removeAllLayers)
# For processing module
self.destCrs = None
......@@ -102,7 +102,7 @@ class QgisInterface(QObject):
def newProject(self):
"""Create new project."""
# noinspection PyArgumentList
QgsMapLayerRegistry.instance().removeAllMapLayers()
QgsProject.instance().removeAllMapLayers()
# ---------------- API Mock for QgsInterface follows -------------------
......@@ -150,7 +150,7 @@ class QgisInterface(QObject):
def activeLayer(self):
"""Get pointer to the active layer (layer selected in the legend)."""
# noinspection PyArgumentList
layers = QgsMapLayerRegistry.instance().mapLayers()
layers = QgsProject.instance().mapLayers()
for item in layers:
return layers[item]
......
# coding=utf-8
"""Tests QGIS plugin init."""
__author__ = 'Tim Sutton <tim@linfiniti.com>'
__revision__ = '$Format:%H$'
__date__ = '17/10/2010'
__license__ = "GPL"
__copyright__ = 'Copyright 2012, Australia Indonesia Facility for '
__copyright__ += 'Disaster Reduction'
import os
import unittest
import logging
import configparser
LOGGER = logging.getLogger('QGIS')
# -*- coding: utf-8 -*-
"""
***************************************************************************
---------------------
Date : 30.11.2017
Copyright : (C) 2017 by Benjamin Jakimow
Email : benjamin jakimow at geo dot hu-berlin dot de
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
# noinspection PyPep8Naming
import os, sys, unittest, configparser
class TestInit(unittest.TestCase):
"""Test that the plugin init is usable for QGIS.
......@@ -45,7 +48,7 @@ class TestInit(unittest.TestCase):
file_path = os.path.abspath(os.path.join(
os.path.dirname(__file__), os.pardir,
'metadata.txt'))
LOGGER.info(file_path)
metadata = []
parser = configparser.ConfigParser()
parser.optionxform = str
......
# coding=utf-8
"""Safe Translations Test.
# -*- coding: utf-8 -*-
.. note:: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"""
***************************************************************************
---------------------
Date : 30.11.2017
Copyright : (C) 2017 by Benjamin Jakimow
Email : benjamin jakimow at geo dot hu-berlin dot de
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
# noinspection PyPep8Naming
from utilities import get_qgis_app
__author__ = 'ismailsunni@yahoo.co.id'
__date__ = '12/10/2011'
__copyright__ = ('Copyright 2012, Australia Indonesia Facility for '
'Disaster Reduction')
import unittest
import os
import os, unittest
from timeseriesviewer.utils import initQgisApplication
QGIS_APP = initQgisApplication()
......@@ -41,5 +46,36 @@ class TestPlotStyling(unittest.TestCase):
s2 = pickle.loads(pickle.dumps(s1))
self.assertEqual(s1,s2)
def test_dialogs(self):
s1 = PlotStyle()
s1.markerPen.setColor(QColor('yellow'))
s2 = PlotStyle(plotStyle=s1)
self.assertEqual(s1,s2)
d = PlotStyleDialog()
self.assertIsInstance(d, PlotStyleDialog)
try:
d.show()
d.setPlotStyle(s1)
except Exception:
self.fail('Unable to initialize PlotStyleDialog')
self.assertEqual(s1, d.plotStyle())
try:
btn = PlotStyleButton()
btn.show()
except Exception:
self.fail('Unable to initialize PlotStyleButton')
if __name__ == "__main__":
unittest.main()
# -*- coding: utf-8 -*-
"""
***************************************************************************
---------------------
Date : 30.11.2017
Copyright : (C) 2017 by Benjamin Jakimow
Email : benjamin jakimow at geo dot hu-berlin dot de
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
# noinspection PyPep8Naming
import os, sys, unittest
from timeseriesviewer.utils import initQgisApplication
qapp = initQgisApplication()
from timeseriesviewer.spectrallibraries import *
class TestInit(unittest.TestCase):
def setUp(self):
self.SP = None
self.SPECLIB = None
def test_spectralprofile(self):
spec1 = SpectralProfile()
spec1.setValues([0,4,3,2,1],['-'], [450,500,750, 1000, 1500], 'nm')
values = [('key','value'),('key', 100),('Üä','ÜmlÄute')]
for md in values:
k, v = md
spec1.setMetadata(k,v)
v2 = spec1.metadata(k)
self.assertEqual(v,v2)
self.SP = spec1
def test_spectralLibrary(self):
sl = SpectralLibrary()
sl.addProfile(self.SP)
self.assertEqual(len(sl),1)
self.assertEqual(sl[0], self.SP)
self.SPECLIB = sl
def test_speclibWidget(self):
p = SpectralLibraryWidget()
p.addSpeclib(self.SPECLIB)
p.show()
pass
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment