astro.test package

Subpackages

Submodules

astro.test.connection_test module

class astro.test.connection_test.TestNetworkConnectionToDatabase(methodName='runTest')

Bases: unittest.case.TestCase

setUp()
test_dispatcher_connection()
test_domain()
test_node_connection()
test_oracle_connection()
test_oracle_dispatchers()
test_scan_connection()
astro.test.connection_test.connect(hostname, port, timeout)
astro.test.connection_test.oracle_connect(connectstring, timeout)
astro.test.connection_test.timeoutoccurred(*args, **kwargs)

astro.test.dependency_test module

Test to see if the various required packages are available

astro.test.dependency_test.get_version_bertin(program_name)

Function to extract the version of Sextractor, SWarp

astro.test.dependency_test.get_version_cosmicfits(program_name)
astro.test.dependency_test.get_version_cx_oracle()
astro.test.dependency_test.get_version_eclipse()
astro.test.dependency_test.get_version_ellipfit(program_name)
astro.test.dependency_test.get_version_galfit(program_name)
astro.test.dependency_test.get_version_ldac(program_name)

Function to extract the version of an ldac program

astro.test.dependency_test.get_version_ldactoasc(program_name)
astro.test.dependency_test.get_version_numpy()
astro.test.dependency_test.get_version_pyfits()
astro.test.dependency_test.get_version_pylab()
astro.test.dependency_test.get_version_tiny1(program_name)
astro.test.dependency_test.get_version_tiny2(program_name)
astro.test.dependency_test.get_version_tiny3(program_name)
astro.test.dependency_test.get_version_wcstools(program_name)
class astro.test.dependency_test.testEnvironment(methodName='runTest')

Bases: unittest.case.TestCase

test_astro_refcat()
test_oracle_home()

ORACLE_HOME should not have a trailing /

class astro.test.dependency_test.testExternalPrograms(methodName='runTest')

Bases: astro.test.multicasetest.TestMultipleCases

cases = ['add_image_calibs', 'aplastrom', 'aplphotom', 'asctoldac', 'associate', 'astrom', 'preastrom', 'prephotom', 'photom', 'ldacaddkey', 'ldacconcat', 'ldacconv', 'ldacdelkey', 'ldacdesc', 'ldacfilter', 'ldacjoinkey', 'ldacpaste', 'ldacrenkey', 'ldacseparate', 'ldactoasc', 'make_distort', 'make_ssc', 'cosmicfits', 'ellipfit', 'fitscopy', 'galfit', 'imcopy', 'psfex', 'scamp', 'sex', 'stiff', 'swarp', 'tiny1', 'tiny2', 'tiny3', 'gaap-corr.csh', 'gpsf-noplots.csh']
test_programs(program_name)

Test availability of external programs

test_versions(program_name)

Test versions of external programs

class astro.test.dependency_test.testPythonModules(methodName='runTest')

Bases: astro.test.multicasetest.TestMultipleCases

cases = ['cx_Oracle', 'eclipse', 'numpy', 'pyfits', 'pylab']
test_dependency(module_name)

Test availability of Python modules

test_versions(module_name)

astro.test.dpu_unittestjob module

class astro.test.dpu_unittestjob.UnitTestJob(url=None, tests=None, env={})

Bases: object

env = {}
execute()
tests = ['functional', 'processing', 'recipes', 'services', 'filerecipes', 'database']
url = 'http://drive.astro-wise.org:8000/unittestdata/'
astro.test.dpu_unittestjob.main()

astro.test.dpu_unittests module

astro.test.dpu_unittests.getresults(c, jobid, tests)
astro.test.dpu_unittests.main()

astro.test.firewall_test module

class astro.test.firewall_test.TestNetworkConnectionToDatabase(methodName='runTest')

Bases: unittest.case.TestCase

setUp()
test_node_connection()
astro.test.firewall_test.connect(hostname, port, timeout)

astro.test.make_test_data module

A module defining functions to produce test data, independent of the pipline BaseFrame and derived functionality.

astro.test.make_test_data.make_domeflat_testdata(xsize, ysize, gain=3.0, base_noise=0.0, photons=200, basename='domeflat_test', exptimes=[2, 60, 50, 4, 8, 40, 30, 1, 16, 24])

Make testdata for fomeflat

xsize, ysize – dimension of testimages gain – the gain value to simulate photons – the number of photons in a 1 second exposure exptimes – a list of exposure times

Make a series of images for which: median = exptimes[i]*gain*photons rms = sqrt(base_noise^2+phot_noise^2) phot_noise = sqrt(exptimes[i]*photons)*gain

Also writes the statistics to basename.dat

astro.test.make_test_data.make_gain_testdata(xsize, ysize, gain=3.0, base_noise=0.0, photons=200, basename='gain_test', exptimes=[2, 60, 50, 4, 8, 40, 30, 1, 16, 24])

Make testdata for gain

xsize, ysize – dimension of testimages gain – the gain value to simulate photons – the number of photons in a 1 second exposure exptimes – a list of exposure times

Make a series of images for which: median = exptimes[i]*gain*photons rms = sqrt(base_noise^2+phot_noise^2) phot_noise = sqrt(exptimes[i]*photons)*gain

Also writes the statistics to basename.dat

astro.test.matplotlib_agg module

Import matplotlib with the Agg backend.

The Agg backend is useful when no screen is available or screen output is undesirable. For example when running tests.

Setting the matplotlib Agg backend must be done before importing pyplot, and therefore has to be done before importing e.g. InspectFigure:

import matplotlib matplotlib.use(‘Agg’) import InspectFigure

PEP8 wants module level imports before code execution, and will therefore complain about the above solution. This is not necessarily a problem but cannot be ignored locally in many editors, e.g. PyCharm.

Another solution is to switch the backend after importing:

import InspectFigure import matplotlib.pyplot matplotlib.pyplot.switch_backend(‘Agg’)

However, this is not supported in the default Astro-WISE matplotlib (1.0.0).

Therefore, the simplest solution that produces no PEP8 warnings is to use this module.

import matplotlib_agg import InspectFigure

astro.test.multicasetest module

class astro.test.multicasetest.TestMultipleCases(methodName='runTest')

Bases: unittest.case.TestCase

A class whose instances test multiple cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

Instances should define an iterable atribute ‘cases’. The test methods will be called once for each item in self.cases. Each case may generate its own failure or error. Therefore each test method may generate multiple failures/errors. A test method is deemed to have passed succesfully if none of the cases genereated an error

The cases attribute can be generated at class definition time, at initialization time or in the setUp method

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run. Hence, the __init__ method should not be changed to pass a list of cases to the instance

cases = None

astro.test.regression_test module

Regression testing framework

Adapted from: http://www.diveintopython.org/regression_divein.html

class astro.test.regression_test.RegressionTestResult

Bases: unittest.result.TestResult

A helper class to keep track of successful tests too.

addSuccess(test)
astro.test.regression_test.database_test()

Execute the tests from test modules in database/

astro.test.regression_test.filerecipes_test()

Execute the tests from test modules in filerecipes/

astro.test.regression_test.functional_test()

Execute the tests from test modules in functional/

astro.test.regression_test.get_files(path, pattern)

Return a list of files matching pattern from path.

astro.test.regression_test.get_modules(files)

Return a list of modules imported from the list of files.

astro.test.regression_test.main()
astro.test.regression_test.omegacen_test()

Execute the tests from test modules in omegacen/

astro.test.regression_test.processing_test()

Execute the tests from test modules in processing/

astro.test.regression_test.recipes_test()

Execute the tests from test modules in recipes/

astro.test.regression_test.regression_test(path, pattern='*test.py')

Build a test_suite from test_cases defined in files in path matching pattern.

astro.test.regression_test.services_test()

Execute the tests from test modules in services/

astro.test.regression_test.test_module(module)
astro.test.regression_test.test_module_as_script(module, infix)

astro.test.startup_test module

Test to see if the various required packages are available

class astro.test.startup_test.EnvironmentTest

Bases: object

directories = ['baseconf_dir', 'log_dir', 'testdata_dir']
test()
test_astro_refcat()
test_existence(environment_key)

Test existence of directories defined in Env

test_oracle_home()

ORACLE_HOME should not have a trailing /

class astro.test.startup_test.ExternalProgramsTest

Bases: object

no_version_tag = ['cosmicfits', 'imcopy', 'fitscopy', 'ellipfit', 'gaap-corr.csh', 'gpsf-noplots.csh']
not_installed = ['tiny1', 'tiny2', 'tiny3']
programs = ['add_image_calibs', 'aplastrom', 'aplphotom', 'asctoldac', 'associate', 'astrom', 'preastrom', 'prephotom', 'photom', 'ldacaddkey', 'ldacconcat', 'ldacconv', 'ldacdelkey', 'ldacdesc', 'ldacfilter', 'ldacjoinkey', 'ldacpaste', 'ldacrenkey', 'ldacseparate', 'ldactoasc', 'make_distort', 'make_ssc', 'cosmicfits', 'ellipfit', 'fitscopy', 'galfit', 'imcopy', 'psfex', 'scamp', 'sex', 'stiff', 'swarp', 'tiny1', 'tiny2', 'tiny3', 'gaap-corr.csh', 'gpsf-noplots.csh']
test()
test_program(program_name)

Test availability of external programs

test_version(program_name)

Test versions of external programs

version_map = {'add_image_calibs': (<function get_version_ldac at 0x7f931eeb2d08>, '1.3.3'), 'aplastrom': (<function get_version_ldac at 0x7f931eeb2d08>, '1.1.1'), 'aplphotom': (<function get_version_ldac at 0x7f931eeb2d08>, '1.6.1'), 'asctoldac': (<function get_version_ldac at 0x7f931eeb2d08>, '0'), 'associate': (<function get_version_ldac at 0x7f931eeb2d08>, '1.3.4'), 'astrom': (<function get_version_ldac at 0x7f931eeb2d08>, '1.1.0'), 'cosmicfits': (<function get_version_cosmicfits at 0x7f931eeb2ae8>, '0'), 'ellipfit': (<function get_version_ellipfit at 0x7f931eeb2bf8>, '0'), 'fitscopy': (<function get_version_wcstools at 0x7f931bf52048>, '0'), 'galfit': (<function get_version_galfit at 0x7f931eeb2c80>, '2.0.3c'), 'imcopy': (<function get_version_wcstools at 0x7f931bf52048>, '0'), 'ldacaddkey': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0'), 'ldacconcat': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0'), 'ldacconv': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0.0'), 'ldacdelkey': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0'), 'ldacdesc': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0'), 'ldacfilter': (<function get_version_ldac at 0x7f931eeb2d08>, '1.3.1'), 'ldacjoinkey': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0'), 'ldacpaste': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0'), 'ldacrenkey': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0'), 'ldacseparate': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0'), 'ldactoasc': (<function get_version_ldac at 0x7f931eeb2d08>, '1.0'), 'make_distort': (<function get_version_ldac at 0x7f931eeb2d08>, '1.1.1'), 'make_ssc': (<function get_version_ldac at 0x7f931eeb2d08>, '2.0.3'), 'photom': (<function get_version_ldac at 0x7f931eeb2d08>, '1.1'), 'preastrom': (<function get_version_ldac at 0x7f931eeb2d08>, '2.0.2'), 'prephotom': (<function get_version_ldac at 0x7f931eeb2d08>, '2.3'), 'psfex': (<function get_version_bertin at 0x7f931eeb2a60>, '3.17.1'), 'scamp': (<function get_version_bertin at 0x7f931eeb2a60>, '1.7.0'), 'sex': (<function get_version_bertin at 0x7f931eeb2a60>, '2.8.6'), 'stiff': (<function get_version_bertin at 0x7f931eeb2a60>, '2.1.3'), 'swarp': (<function get_version_bertin at 0x7f931eeb2a60>, '2.17.6'), 'tiny1': (<function get_version_tiny1 at 0x7f931eeb2e18>, '6.3'), 'tiny2': (<function get_version_tiny2 at 0x7f931eeb2ea0>, '6.3'), 'tiny3': (<function get_version_tiny3 at 0x7f931eeb2f28>, '6.3')}
class astro.test.startup_test.PythonModulesTest

Bases: object

modules = ['cx_Oracle', 'eclipse', 'numpy', 'pyfits', 'pylab']
test()
test_module(module_name)

Test availability of Python modules

test_version(module_name)
astro.test.startup_test.startup_test()

astro.test.testpath module

Path to testdata

astro.test.testpath.get_abspath(filename)

Return the complete absolute path for a file

astro.test.testpath.localpath(pathname)

Create a local symlink.

astro.test.testpath.testpath(fname)

Join fname to Env[‘testdata_dir’]

Module contents

Procedures to test the functionality and integrity of the software

This packag contains packages/modules and a few scripts to be used from the command-line.

Package/Module | Provided functionality

multicasetest | Module containing framework for handling multiple test cases
that differ only in a single aspect.

functional | Package containing all functional tests. processing | Package containing all processing tests. recipes | Package containing all recipes tests. filerecipes | ? services | ? database | ? omegacen | Tests that rely on the OmegaCEN infrastructure specifics. ——————————————————————————–

Additionally the following scripts are available in the astro/test directory :

dependency_test.py - Verifies the existence of required packages. regression_test.py - Runs all functional, processing and/or recipes tests. make_test_data.py - Produces test data.