test_utils

Utility tools for writing unit tests for packages which rely on sentinelhub-py

class sentinelhub.test_utils.TestSentinelHub(methodName='runTest')[source]

Bases: unittest.case.TestCase

Class implementing common functionalities of unit tests for working with sentinelhub-py package:

  • reading configuration parameters from environmental variables and saving them to config.json,
  • setting logger,
  • handling input and output data folders,
  • method for testing statistics of a numpy data array.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

classmethod setUpClass()[source]

A general set up class

Use super().setUpClass() in every class which inherits TestSentinelHub

classmethod tearDownClass()[source]

Hook method for deconstructing the class fixture after running all tests in the class.

test_numpy_data(data=None, exp_shape=None, exp_dtype=None, exp_min=None, exp_max=None, exp_mean=None, exp_median=None, delta=None, test_name='')[source]

Validates basic statistics of data array

Parameters:
  • data (numpy.ndarray) – Data array
  • exp_shape (tuple(int)) – Expected shape
  • exp_dtype (numpy.dtype) – Expected dtype
  • exp_min (float) – Expected minimal value
  • exp_max (float) – Expected maximal value
  • exp_mean (float) – Expected mean value
  • exp_median (float) – Expected median value
  • delta (float) – Precision of validation. If not set, it will be set automatically
  • test_name (str) – Name of the test case
class sentinelhub.test_utils.TestCaseContainer(name, request, **stats)[source]

Bases: object

Class for storing expected statistics for a single test case

Parameters:
  • name (str) – Name of a test case
  • request (object) – A class which provides the data for testing
  • stats – Any other parameters