autowisp.tests.test_diagnostic_expressions module

Class Inheritance Diagram

Inheritance diagram of DiagnosticExpressionForm, ExpressionLibraryTestCase, IntegrityError, TestDeleteAndWrite, TestExpressionForm, TestLibraryAccess, TestNameSpace, TestStoreExpression, TestStoredFields

Tests for the diagnostic expression library stored in a project.

The library is read and written through autowisp.diagnostics.expression_library, against a throwaway project database. What an expression means is tested where those rules live, in the expression layer’s own tests; here it is only what gets stored, and that references survive a rename.

The management form is tested here too, for the one check it makes itself rather than delegating: that a name is a slug and is not already taken.

class autowisp.tests.test_diagnostic_expressions.ExpressionLibraryTestCase(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_diagnostic_expressions.ExpressionLibraryTestCase

Base creating one throwaway project, emptied before every test.

static library()[source]

The stored library, {name: expression}.

static make(name, expression='astrom_residual[0] / diagonal_fov[0]', **kw)[source]

Store one expression, returning what the store reported.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

classmethod tearDownClass()[source]

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

class autowisp.tests.test_diagnostic_expressions.TestDeleteAndWrite(methodName='runTest')[source]

Bases: ExpressionLibraryTestCase

Inheritance diagram of autowisp.tests.test_diagnostic_expressions.TestDeleteAndWrite

Deleting several, and writing an import’s worth at once.

test_delete_only_the_named()[source]

Other expressions, and names not stored, are left alone.

test_write_counts_added_and_replaced()[source]

New names are added, existing ones overwritten, and counted.

class autowisp.tests.test_diagnostic_expressions.TestExpressionForm(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_diagnostic_expressions.TestExpressionForm

The name checks the management form makes itself.

form(name, replacing=None)[source]

Bind the form to one proposed expression.

library = {'rel_bg': 'bg_center[0] - nanmedian(bg_center[0])'}
test_a_slug_name_is_accepted()[source]

The names the documentation suggests actually validate.

test_a_taken_name_is_refused()[source]

Adding under a stored name would replace it without asking.

test_editing_keeps_its_own_name()[source]

The expression being edited does not clash with itself.

test_name_must_survive_a_url()[source]

Rejected unless it is a slug.

Expressions are selected through image/<slug:x>/vs/<slug:y>, so a name outside the slug charset could be stored but never plotted.

test_renaming_onto_another_is_refused()[source]

A rename may not take a name some other expression has.

class autowisp.tests.test_diagnostic_expressions.TestLibraryAccess(methodName='runTest')[source]

Bases: ExpressionLibraryTestCase

Inheritance diagram of autowisp.tests.test_diagnostic_expressions.TestLibraryAccess

What reading hands to the expression layer and to an export.

test_empty_library_is_a_dictionary()[source]

Not None: the layers below iterate it without checking.

test_entries_for_export()[source]

Every stored field, by name, skipping names not stored.

test_names_map_to_their_text()[source]

The shape the expression layer expects, and nothing more.

class autowisp.tests.test_diagnostic_expressions.TestNameSpace(methodName='runTest')[source]

Bases: ExpressionLibraryTestCase

Inheritance diagram of autowisp.tests.test_diagnostic_expressions.TestNameSpace

Names have to behave like the diagnostic names they sit beside.

test_name_is_unique()[source]

Two expressions cannot share a name.

The name is what a selector and a URL carry, and what other expressions and exclusion rules reference, so a duplicate would be ambiguous everywhere at once. The form refuses one first; this is the database guaranteeing it regardless.

class autowisp.tests.test_diagnostic_expressions.TestStoreExpression(methodName='runTest')[source]

Bases: ExpressionLibraryTestCase

Inheritance diagram of autowisp.tests.test_diagnostic_expressions.TestStoreExpression

Adding, replacing and renaming one expression.

test_rename_carries_the_dependents()[source]

What referenced the old name references the new one.

Leaving them naming something that no longer exists would break them, and refusing the rename would not help: a dependent cannot be pointed at the new name before it exists.

test_replacing_a_name_not_stored_adds()[source]

A stale edit link adds the expression rather than losing it.

test_replacing_keeps_the_name()[source]

An edit that keeps the name changes the text in place.

class autowisp.tests.test_diagnostic_expressions.TestStoredFields(methodName='runTest')[source]

Bases: ExpressionLibraryTestCase

Inheritance diagram of autowisp.tests.test_diagnostic_expressions.TestStoredFields

What the library keeps, and what it deliberately does not check.

test_description_is_optional()[source]

Most expressions are self-explanatory from their text.

test_unknown_names_are_not_rejected_here()[source]

The library stores text; resolving names is not its job.

An expression may legitimately reference diagnostics the project has never recorded – it is then simply not offered – so refusing it here would be wrong.