Commit 8e8940a1 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'master' into Tests

Conflicts:
	tests/test_geoarray.py
parent 99b84781
......@@ -7,20 +7,20 @@
test_geoarray
----------------------------------
Tests for the functions of the "GeoArray"-class in the "geoarray" module.
For this purpose the TIFF-file "L8_2bands_extract10x11.tif" and the array of
the TIFF-image "L8_2bands_extract10x11_array.txt" in the directory "../tests/data"
is used. The outputs of the "GeoArray"-class functions are tested against the well
Tests for the functions of the "GeoArray"-class in the "geoarray" module.
For this purpose the TIFF-file "L8_2bands_extract10x11.tif" and the array of
the TIFF-image "L8_2bands_extract10x11_array.txt" in the directory "../tests/data"
is used. The outputs of the "GeoArray"-class functions are tested against the well
known properties of the test-image.
The tests are divided into a total of two test cases. The order of execution is as
follows:
follows:
test case 1 (path) - test case 2 (path) - test case 1 (array) - test case 2 (array).
Note that the tests in the test case "Test_GeoarrayAppliedOnPathArray" and
"Test_GeoarrayFunctions" follow - with a few exceptions - the same order as in the
Note that the tests in the test case "Test_GeoarrayAppliedOnPathArray" and
"Test_GeoarrayFunctions" follow - with a few exceptions - the same order as in the
"GeoArray"-class (but they are executed in alphanumeric order inside the test case).
Functions that depend on each other are tested together.
Functions that depend on each other are tested together.
Program started in Mai 2017.
"""
......@@ -48,7 +48,7 @@ from unittest import TestLoader
import geoarray
from geoarray import GeoArray
from geoarray import masks
from py_tools_ds.ptds.geo.vector import geometry
from py_tools_ds.geo.vector import geometry
# Path of the tests-directory in the geoarray-package.
......@@ -60,16 +60,16 @@ tests_path = os.path.abspath(path.join(geoarray.__file__,"../.."))
class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
"""
The class "Test_GeoarrayAppliedOnPathArray" tests the basic functions of the
The class "Test_GeoarrayAppliedOnPathArray" tests the basic functions of the
"GeoArray"-class from which the other functions depend on. The functions that
are being tested are stated in the docstrings located at the beginning of each
test. Note that the function set_gdalDataset_meta is tested indirectly by a
are being tested are stated in the docstrings located at the beginning of each
test. Note that the function set_gdalDataset_meta is tested indirectly by a
couple of tests in the test case (a notation is applied).
Since the "GeoArray"-class can be instanced with a file path or with a numpy
Since the "GeoArray"-class can be instanced with a file path or with a numpy
array and the corresponding geoinformation, the tests in this test case will
be executed two times in a row (the test case is parametrized). The order is
as follows: In the first/second round the tests will be executed using the
as follows: In the first/second round the tests will be executed using the
"GeoArray"-instance created with a file path/numpy array.
"""
......@@ -135,7 +135,7 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
def TiffIsInstanceOfGeoarray(self):
"""
Indirect test.
Testing, whether the object "testtiff" is an instance of the class "GeoArray" or not. If an exception is
Testing, whether the object "testtiff" is an instance of the class "GeoArray" or not. If an exception is
raised for an error, all tests of the test case "Test_GeoarrayAppliedOnTiffPath" will be skipped.
"""
......@@ -152,8 +152,8 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
"""
Testing the functions: arr - is_inmem, indirect test with 2 stages.
Stage 1: Checking, if the argument passed to the "GeoArray"-class is a file path or a numpy.ndarray.
Stage 2: It is tested, if the arr- and is_inmem-function give the expected output.
If, for any possibility that was tested, an exception is raised for an error, all tests of the test case
Stage 2: It is tested, if the arr- and is_inmem-function give the expected output.
If, for any possibility that was tested, an exception is raised for an error, all tests of the test case
"Test_GeoarrayAppliedOnTiffPath" will be skipped.
"""
......@@ -197,7 +197,7 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
def test_Bandnames(self):
"""
Testing the function: bandnames.
Test, if the default band names were correctly assigned.
Test, if the default band names were correctly assigned.
"""
self.assertEqual(self.testtiff.bandnames, self.expected_bandnames,
......@@ -207,13 +207,13 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
def test_ShapeOfTiffArray(self):
"""
Testing the functions: shape - ndim - rows - columns - bands,
indirect testing of the function: set_gdalDataset_meta(!),
Testing the functions: shape - ndim - rows - columns - bands,
indirect testing of the function: set_gdalDataset_meta(!),
test with 2 stages.
Stage 1: Comparing the shape of the testtiff-image with the output of the shape-function.
When identical, induction of stage 2...
Stage 2: Comparing the output of the ndim-, rows-, columns- and bands-function with the expected results.
If the the shape of the image is not as expected (Stage 1), the whole test will be skipped.
If the the shape of the image is not as expected (Stage 1), the whole test will be skipped.
"""
testtiff_shapefunctions = (self.testtiff.ndim, self.testtiff.rows, self.testtiff.columns, self.testtiff.bands)
......@@ -234,7 +234,7 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
def test_DtypeOfTiffArray(self):
"""
Testing the function: dtype,
Testing the function: dtype,
indirect testing of the function: set_gdalDataset_meta(!).
Test, if the data type of the .ndarray behind the "GeoArray"-class was correctly assigned.
"""
......@@ -246,14 +246,14 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
def test_GeotransformTiff(self):
"""
Testing the functions: geotransform - xgsd - ygsd - xygrid_specs,
indirect testing of the function: set_gdalDataset_meta(!),
Testing the functions: geotransform - xgsd - ygsd - xygrid_specs,
indirect testing of the function: set_gdalDataset_meta(!),
test with 3 stages.
Stage 1: Comparing the geotransform-tupel of the geotransform-function with the expected result.
Stage 1: Comparing the geotransform-tupel of the geotransform-function with the expected result.
When identical, induction of stage 2...
Stage 2: Comparing the resolution from the geotransform-tupel with the expected resolution.
Stage 2: Comparing the resolution from the geotransform-tupel with the expected resolution.
When identical, induction of stage 3...
Stage 3: Comparing the x/y coordinate grid by the xygrid_specs-function with the expected result.
Stage 3: Comparing the x/y coordinate grid by the xygrid_specs-function with the expected result.
If an exception is raised as an error in stage 1 or 2, the test will be skipped.
"""
......@@ -276,8 +276,8 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
def test_ProjectionTiff(self):
"""
Testing the functions: projection - epsg,
indirect testing of the function: set_gdalDataset_meta(!),
Testing the functions: projection - epsg,
indirect testing of the function: set_gdalDataset_meta(!),
test with 2 stages.
Stage 1: After translating the projection-string provided by the projection-function to a pszProj4-string,
it is compared to the expected pszProj4-string. When identical, induction of stage 2...
......@@ -310,7 +310,7 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
"""
Testing the function: nodata,
indirect testing of the function: set_gdalDataset_meta(!).
Test, if the nodata value of the image was correctly assigned.
Test, if the nodata value of the image was correctly assigned.
"""
self.assertEqual(self.testtiff.nodata, self.given_nodata,
......@@ -329,26 +329,26 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
class Test_GeoarrayFunctions(unittest.TestCase):
"""
*** !!!
Note that the class "Test_GeoarrayFunctions" is NOT complete. Furthermore,
part of the tests that are contained in this test case are not completely
independent - some dependencies that can be found in the source code of the
function that is being tested is not yet considered. A respective comment
*** !!!
Note that the class "Test_GeoarrayFunctions" is NOT complete. Furthermore,
part of the tests that are contained in this test case are not completely
independent - some dependencies that can be found in the source code of the
function that is being tested is not yet considered. A respective comment
can be found at the beginning of the affected tests in the "TODO"-statement. ***
The class "Test_GeoarrayFunctions" is the second test case of the
"test_geoarray"-script and tests the functions of the "GeoArray"-class that are
not yet tested in the first test case. Since the basic functions on which most
functions of the "GeoArray"-class depend on were already tested in test case 1,
the tests of test case 2 can be considered moderately independent from these
functions. Note that if an error, failure or skip occurs in test case 1, test
case 2 will not be executed. If test case 1 was successful, test case 2 will be
executed twice - like test case 1 test case 2 is parametrized. The order of
execution is as follows:
After the first test case is executed using the "GeoArray"-instance created
with a file path, the second test case is executed using the same instance.
The second execution of the test cases uses the "GeoArray"-instance created
The class "Test_GeoarrayFunctions" is the second test case of the
"test_geoarray"-script and tests the functions of the "GeoArray"-class that are
not yet tested in the first test case. Since the basic functions on which most
functions of the "GeoArray"-class depend on were already tested in test case 1,
the tests of test case 2 can be considered moderately independent from these
functions. Note that if an error, failure or skip occurs in test case 1, test
case 2 will not be executed. If test case 1 was successful, test case 2 will be
executed twice - like test case 1 test case 2 is parametrized. The order of
execution is as follows:
After the first test case is executed using the "GeoArray"-instance created
with a file path, the second test case is executed using the same instance.
The second execution of the test cases uses the "GeoArray"-instance created
with a numpy array.
"""
......@@ -414,7 +414,7 @@ class Test_GeoarrayFunctions(unittest.TestCase):
# TODO: Setting a baddata mask and testing, if mask_baddata is an instance of the BadDataMask-class (masks.py).
"""
Testing the function: mask_baddata.
Test, if the output of the mask_baddata-function is "None" since a baddata-mask is not set within the used
Test, if the output of the mask_baddata-function is "None" since a baddata-mask is not set within the used
TIFF-image.
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment