Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EO Time Series Viewer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Jakimow
EO Time Series Viewer
Commits
5a51e8bd
Commit
5a51e8bd
authored
7 years ago
by
benjamin.jakimow@geo.hu-berlin.de
Browse files
Options
Downloads
Patches
Plain Diff
added & refactored /tests
parent
a2f50b96
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
test/qgis_interface.py
+6
-6
6 additions, 6 deletions
test/qgis_interface.py
test/test_init.py
+22
-19
22 additions, 19 deletions
test/test_init.py
test/test_plotstyling.py
+49
-13
49 additions, 13 deletions
test/test_plotstyling.py
test/test_spectrallibraries.py
+72
-0
72 additions, 0 deletions
test/test_spectrallibraries.py
with
149 additions
and
38 deletions
test/qgis_interface.py
+
6
−
6
View file @
5a51e8bd
...
...
@@ -25,7 +25,7 @@ __copyright__ = (
import
logging
from
PyQt5.QtCore
import
QObject
,
pyqtSlot
,
pyqtSignal
from
qgis.core
import
Qgs
MapLayerRegistry
from
qgis.core
import
Qgs
Project
from
qgis.gui
import
QgsMapCanvasLayer
LOGGER
=
logging
.
getLogger
(
'
QGIS
'
)
...
...
@@ -49,11 +49,11 @@ class QgisInterface(QObject):
# are added.
LOGGER
.
debug
(
'
Initialising canvas...
'
)
# noinspection PyArgumentList
Qgs
MapLayerRegistry
.
instance
().
layersAdded
.
connect
(
self
.
addLayers
)
Qgs
Project
.
instance
().
layersAdded
.
connect
(
self
.
addLayers
)
# noinspection PyArgumentList
Qgs
MapLayerRegistry
.
instance
().
layerWasAdded
.
connect
(
self
.
addLayer
)
Qgs
Project
.
instance
().
layerWasAdded
.
connect
(
self
.
addLayer
)
# noinspection PyArgumentList
Qgs
MapLayerRegistry
.
instance
().
removeAll
.
connect
(
self
.
removeAllLayers
)
Qgs
Project
.
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
Qgs
MapLayerRegistry
.
instance
().
removeAllMapLayers
()
Qgs
Project
.
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
=
Qgs
MapLayerRegistry
.
instance
().
mapLayers
()
layers
=
Qgs
Project
.
instance
().
mapLayers
()
for
item
in
layers
:
return
layers
[
item
]
...
...
This diff is collapsed.
Click to expand it.
test/test_init.py
+
22
−
19
View file @
5a51e8bd
# 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
...
...
This diff is collapsed.
Click to expand it.
test/test_plotstyling.py
+
49
−
13
View file @
5a51e8bd
# 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
()
This diff is collapsed.
Click to expand it.
test/test_spectrallibraries.py
0 → 100644
+
72
−
0
View file @
5a51e8bd
# -*- 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
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment