From 94bc4157cd9bb482ece13b01d9f6eea9ecf9577e Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 5 Oct 2012 23:39:08 +0200 Subject: [PATCH] Added simple point test used in demo at hackfest in Essen --- tests/src/python/CMakeLists.txt | 1 + tests/src/python/test_qgsgeometry.py | 1 + tests/src/python/test_qgspoint.py | 53 ++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tests/src/python/test_qgspoint.py diff --git a/tests/src/python/CMakeLists.txt b/tests/src/python/CMakeLists.txt index 3f71ba8ca14..f172267f840 100644 --- a/tests/src/python/CMakeLists.txt +++ b/tests/src/python/CMakeLists.txt @@ -14,3 +14,4 @@ ADD_PYTHON_TEST(PyQgsComposition test_qgscomposition.py) ADD_PYTHON_TEST(PyQgsAnalysis test_qgsanalysis.py) #ADD_PYTHON_TEST(PyQgsComposerMap test_qgscomposermap.py) ADD_PYTHON_TEST(PyQgsSymbolLayerV2 test_qgssymbollayerv2.py) +ADD_PYTHON_TEST(PyQgsPoint test_qgspoint.py) diff --git a/tests/src/python/test_qgsgeometry.py b/tests/src/python/test_qgsgeometry.py index ae504c4549d..e0ddc833eeb 100644 --- a/tests/src/python/test_qgsgeometry.py +++ b/tests/src/python/test_qgsgeometry.py @@ -23,6 +23,7 @@ from utilities import (getQgisTestApp, unittest) # Convenience instances in case you may need them # not used in this test + QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp() class TestQgsGeometry(TestCase): diff --git a/tests/src/python/test_qgspoint.py b/tests/src/python/test_qgspoint.py new file mode 100644 index 00000000000..31beb1b5147 --- /dev/null +++ b/tests/src/python/test_qgspoint.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +"""QGIS Unit tests for QgsPoint. + +.. 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. +""" +__author__ = 'Tim Sutton' +__date__ = '20/08/2012' +__copyright__ = 'Copyright 2012, The Quantum GIS Project' +# This will get replaced with a git SHA1 when you do a git archive +__revision__ = '$Format:%H$' + +import os + +from qgis.core import QgsPoint + +from utilities import (unitTestDataPath, + getQgisTestApp, + TestCase, + unittest, + expectedFailure + ) + +QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp() + +class TestQgsPoint(TestCase): + + def __init__(self, methodName): + """Run once on class initialisation.""" + unittest.TestCase.__init__(self, methodName) + + + def setUp(self): + self.mPoint = QgsPoint(10.0, 10.0) + + def test_Point(self): + myExpectedValue = 10.0 + myActualValue = self.mPoint.x() + myMessage = 'Expected: %s Got: %s' % (myExpectedValue, myActualValue) + assert myExpectedValue == myActualValue, myMessage + + + def test_pointToString(self): + myExpectedValue = '10, 10' + myActualValue = self.mPoint.toString() + myMessage = 'Expected: %s Got: %s' % (myExpectedValue, myActualValue) + assert myExpectedValue == myActualValue, myMessage + + +if __name__ == '__main__': + unittest.main()