llama.test.classes module

Classes used in unit tests for LLAMA.

class llama.test.classes.AbstractFileGenerationChecker

Bases: llama.test.classes.AbstractFileGenerationComparator

Just like AbstractFileGenerationComparator, but does not compare file contents of outputs to a nominal value; instead, just checks whether the expected output files exist. Use this for files that do not depend deterministically on their inputs (and cannot therefore be compared with a simple diff to expected outputs).

compare()

Check whether running execute in the test eventdir has produced all of the expected output files. Does not check contents. Use this for files whose contents do not deterministically depend on input files.

Returns

events_equalTrue if the output is exactly as expected. False in any other case.

Return type

bool

class llama.test.classes.AbstractFileGenerationComparator

Bases: abc.ABC

A class for running a test that produces some sort of expected output files for a given event and testing whether those output files are as expected by comparing them to reference files that are assumed correct. This class should be used to implement unit tests for the actual file generation steps of each step in the pipeline (including external triggering).

abstract property EVENTID

The eventid (i.e. the directory name) of the scenario that is being tested. Must correspond to an Event in TEST_RUN_INPUTS (i.e. EVENTID must be a directory in run.rundir for some run in TEST_RUN_INPUTS).

INPUT_RUN = Run(rundir="/root/.local/share/llama/inputs/tests/event_files", pipeline="Pipeline(<['Advok', 'CoincScatterI3LvcPdf', 'CoincScatterI3LvcPng', 'CoincScatterZtfI3LvcPdf', 'CoincScatterZtfI3LvcPng', 'CoincScatterZtfLVCPdf', 'CoincScatterZtfLVCPng', 'CoincSignificanceI3Lvc', 'CoincSummaryI3LvcPdf', 'CoincSummaryI3LvcTex', 'FermiGRBsJSON', 'IceCubeNeutrinoList', 'IceCubeNeutrinoListCoincTxt', 'IceCubeNeutrinoListTex', 'IceCubeNeutrinoListTxt', 'LVAlertAdvok', 'LVAlertJSON', 'LVCGraceDbEventData', 'LVCInitialXml', 'LVCPreliminaryXml', 'LvcDistancesJson', 'LvcSkymapFits', 'LvcSkymapHdf5', 'PAstro', 'RctSlkI3CoincSummaryI3LvcPdf', 'RctSlkLmaCoincScatterI3LvcPdf', 'RctSlkLmaCoincScatterI3LvcPng', 'RctSlkLmaCoincScatterZtfI3LvcPdf', 'RctSlkLmaCoincScatterZtfI3LvcPng', 'RctSlkLmaCoincScatterZtfLVCPdf', 'RctSlkLmaCoincScatterZtfLVCPng', 'RctSlkLmaCoincSignificanceI3Lvc', 'RctSlkLmaCoincSummaryI3LvcPdf', 'RctSlkLmaLVAlertJSON', 'RctSlkLmaLVCGraceDbEventData', 'RctSlkLmaLVCInitialXml', 'RctSlkLmaLVCPreliminaryXml', 'RctSlkLmaLvcDistancesJson', 'RctSlkLmaSkymapInfo', 'SkymapInfo', 'ZtfTriggerList']>)")
abstract property STARTING_MANIFEST

A tuple of specific FileHandler classes whose files should be copied from the input directory in TEST_RUN_INPUTS to the temporary output test directory. This will set the starting state for the test.

compare()

Compare the outputs of execute in the test eventdir to the expected values in the input Event from TEST_RUN_INPUTS. Checks whether the file contents are strictly equal.

Returns

events_equalTrue if the output is exactly as expected. False in any other case.

Return type

bool

property event

An Event instance corresponding to the output files of this test. Use this instance to get e.g. file locations if necessary.

abstract execute()

Run the actual test (no need to compare outputs; this will be done in compare).

property inputevent

An Event instance corresponding to the input files of this test.

abstract property pipeline

A Pipeline instance defining the output files generated by this test. These are the output files that will be compared by AbstractFileGenerationComparator.compare to make sure that all outputs are as expected (and, as a sanity check, that no inputs have been mutated).

provision()

Link or copy input files from STARTING_MANIFEST into event.eventdir so that they are available for execute. The test directory is presumed to exist.

property run

A temporary Run instance for tests (probably using a pytest fixture) where the test outputs for this test’s EVENTID will reside. Feel free to override this with a custom directory.

test()

Run this test with execute and then check whether outputs are as expected with compare.

class llama.test.classes.MS181101abMixin

Bases: object

Tests on an ER14-era test event from the EM Follow-up userguide.

EVENTID = 'MS181101ab'
class llama.test.classes.S190412mMixin

Bases: object

Tests on S190412m, a manually-triggered BBH event in early O3.

EVENTID = 'S190412m'
class llama.test.classes.S190425zMixin

Bases: object

Tests on S190425z, the first BNS of O3, triggered by GCN Initial notice in this test.

EVENTID = 'S190425z'
class llama.test.classes.S190521gMixin

Bases: object

Tests on S190521g, a BBH event in O3, triggered by GCN Preliminary notice in this test.

EVENTID = 'S190521g'