aiida.backends.tests package

Module for defining tests that required access to (a temporary) database

aiida.backends.tests.get_db_test_list()[source]

This function returns the DB_TEST_LIST for the current backend, merged with the ‘common’ tests.

Note:This function should be called only after setting the backend, and then it returns only the tests for this backend, and the common ones.
aiida.backends.tests.get_db_test_names()[source]

Return a sorted list of test names

Subpackages

Submodules

class aiida.backends.tests.test_backup_setup_script.TestBackupSetupScriptIntegration(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_backup_setup_script'
test_full_backup_setup_script()[source]

This method is a full test of the backup setup script. It launches it, replies to all the question as the user would do and in the end it checks that the correct files were created with the right content.

class aiida.backends.tests.test_backup_setup_script.TestBackupSetupScriptUnit(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_backup_setup_script'
tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

test_construct_backup_variables()[source]

Test that checks that the backup variables are populated as it should by the construct_backup_variables by asking the needed questions. A lambda function is used to simulate the user input.

class aiida.backends.tests.test_base_dataclasses.TestFloat(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_base_dataclasses'
setUp()[source]

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

test_add()[source]
test_create()[source]
test_division()[source]

Test the normal division operator.

test_division_integer()[source]

Test the integer division operator.

test_load()[source]
test_modulo()[source]
test_mul()[source]
test_power()[source]
class aiida.backends.tests.test_base_dataclasses.TestFloatIntMix(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_base_dataclasses'
test_operator()[source]
class aiida.backends.tests.test_base_dataclasses.TestInt(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_base_dataclasses'
test_division()[source]

Test the normal division operator.

test_division_integer()[source]

Test the integer division operator.

test_modulo()[source]
class aiida.backends.tests.test_base_dataclasses.TestList(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_base_dataclasses'
test_append()[source]
test_creation()[source]
test_extend()[source]
test_mutability()[source]
test_store_load()[source]

Tests for the CalculationNode and CalcJobNode class.

class aiida.backends.tests.test_calculation_node.TestProcessNode(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

These tests check the features of process nodes that differ from the base Node type

__module__ = 'aiida.backends.tests.test_calculation_node'
boolval = True
dictval = {'emptydict': {}, 'num': 3, 'recursive': {'boolean': True, 'dictionary': {'empty_dictionary': {}, 'empty_list': [], 'none': None, 'string': 'z'}, 'float': 1.2, 'integer': 1, 'list': [1, 2, None]}, 'something': 'else'}
emptydict = {}
emptylist = []
floatval = 4.56
intval = 123
listval = [1, 's', True, None]
classmethod setUpClass(*args, **kwargs)[source]

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

stateval = 'RUNNING'
stringval = 'aaaa'
test_get_authinfo()[source]

Test that we can get the AuthInfo object from the calculation instance.

test_get_description()[source]
test_get_transport()[source]

Test that we can get the Transport object from the calculation instance.

test_process_node_updatable_attribute()[source]

Check that updatable attributes and only those can be mutated for a stored but unsealed CalculationNode.

test_process_state()[source]

Check the properties of a newly created bare CalculationNode

Tests for specific subclasses of Data

class aiida.backends.tests.test_dataclasses.TestArrayData(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the ArrayData objects.

__module__ = 'aiida.backends.tests.test_dataclasses'
test_creation()[source]

Check the methods to add, remove, modify, and get arrays and array shapes.

test_iteration()[source]

Check the functionality of the get_iterarrays() iterator

class aiida.backends.tests.test_dataclasses.TestBandsData(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the BandsData objects.

__module__ = 'aiida.backends.tests.test_dataclasses'
test_band()[source]

Check the methods to set and retrieve a mesh.

test_export_to_file()[source]

Export the band structure on a file, check if it is working

class aiida.backends.tests.test_dataclasses.TestCifData(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests for CifData class.

class StrictVersion(vstring=None)

Bases: distutils.version.Version

Version numbering for anal retentives and software idealists. Implements the standard interface for version number classes as described above. A version number consists of two or three dot-separated numeric components, with an optional “pre-release” tag on the end. The pre-release tag consists of the letter ‘a’ or ‘b’ followed by a number. If the numeric components of two version numbers are equal, then one with a pre-release tag will always be deemed earlier (lesser) than one without.

The following are valid version numbers (shown in the order that would be obtained by sorting according to the supplied cmp function):

0.4 0.4.0 (these two are equivalent) 0.4.1 0.5a1 0.5b3 0.5 0.9.6 1.0 1.0.4a3 1.0.4b1 1.0.4

The following are examples of invalid version numbers:

1 2.7.2.2 1.3.a4 1.3pl1 1.3c4

The rationale for this version numbering system will be explained in the distutils documentation.

__module__ = 'distutils.version'
__str__()

Return str(self).

_cmp(other)
parse(vstring)
version_re = re.compile('^(\\d+) \\. (\\d+) (\\. (\\d+))? ([ab](\\d+))?$', re.VERBOSE|re.ASCII)
__module__ = 'aiida.backends.tests.test_dataclasses'
get_pymatgen_version()
Returns:string with pymatgen version, None if can not import.
has_ase()
Returns:True if the ase module can be imported, False otherwise.
has_pycifrw()
Returns:True if the PyCifRW module can be imported, False otherwise.
has_pymatgen()
Returns:True if the pymatgen module can be imported, False otherwise.
has_spglib()
Returns:True if the spglib module can be imported, False otherwise.
test_ase_primitive_and_conventional_cells_ase()[source]

Checking the number of atoms per primitive/conventional cell returned by ASE ase.io.read() method. Test input is adapted from http://www.crystallography.net/cod/9012064.cif@120115

test_ase_primitive_and_conventional_cells_pymatgen()[source]

Checking the number of atoms per primitive/conventional cell returned by ASE ase.io.read() method. Test input is adapted from http://www.crystallography.net/cod/9012064.cif@120115

test_attached_hydrogens()[source]
test_change_cifdata_file()[source]
test_cif_roundtrip()[source]
test_cif_with_long_line()[source]

Tests CifData - check that long lines (longer than 2048 characters) are supported. Should not raise any error.

test_empty_cif()[source]

Test empty CifData

Note: This test does not need PyCifRW.

test_get_structure()[source]
test_has_partial_occupancies()[source]
test_has_undefined_atomic_sites()[source]
test_has_unknown_species()[source]
test_parse_cifdata()[source]
test_parse_formula()[source]
test_parse_policy()[source]

Test that loading of CIF file occurs as defined by parse_policy.

test_pycifrw_from_datablocks()[source]

Tests CifData.pycifrw_from_cif()

test_pycifrw_syntax()[source]

Tests CifData.pycifrw_from_cif() - check syntax pb in PyCifRW 3.6

test_refine()[source]

Test case for refinement (space group determination) for a CifData object.

test_reload_cifdata()[source]
test_scan_type()[source]

Check that different scan_types of PyCifRW produce the same result.

test_set_file()[source]

Test that setting a new file clears formulae and spacegroups.

test_symop_string_from_symop_matrix_tr()[source]
valid_sample_cif_str = "\n data_test\n _cell_length_a 10\n _cell_length_b 10\n _cell_length_c 10\n _cell_angle_alpha 90\n _cell_angle_beta 90\n _cell_angle_gamma 90\n _chemical_formula_sum 'C O2'\n loop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n _atom_site_attached_hydrogens\n C 0 0 0 0\n O 0.5 0.5 0.5 .\n H 0.75 0.75 0.75 0\n "
valid_sample_cif_str_2 = "\n data_test\n _cell_length_a 10\n _cell_length_b 10\n _cell_length_c 10\n _cell_angle_alpha 90\n _cell_angle_beta 90\n _cell_angle_gamma 90\n _chemical_formula_sum 'C O'\n loop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n _atom_site_attached_hydrogens\n C 0 0 0 0\n O 0.5 0.5 0.5 .\n "
class aiida.backends.tests.test_dataclasses.TestKindTestGeneral(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the creation of Kind objects and their methods.

__module__ = 'aiida.backends.tests.test_dataclasses'
test_automatic_name()[source]

Check the automatic name generator.

test_no_position()[source]

Should not accept a ‘positions’ parameter

test_simple()[source]

Should recognize a simple element.

test_sum_less_one_general()[source]

Should accept a sum equal less than one

test_sum_one_general()[source]

Should accept a sum equal to one

class aiida.backends.tests.test_dataclasses.TestKindTestMasses(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the management of masses during the creation of Kind objects.

__module__ = 'aiida.backends.tests.test_dataclasses'
test_auto_mass_one()[source]

mass for elements with sum one

test_manual_mass()[source]

mass set manually

test_sum_less_one_masses()[source]

mass for elements with sum less than one

test_sum_less_one_singleelem()[source]

mass for a single element

class aiida.backends.tests.test_dataclasses.TestKindValidSymbols(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the symbol validation of the aiida.orm.nodes.data.structure.Kind class.

__module__ = 'aiida.backends.tests.test_dataclasses'
test_bad_symbol()[source]

Should not accept a non-existing symbol.

test_empty_list_symbols()[source]

Should not accept an empty list

test_unknown_symbol()[source]

Should test if symbol X is valid and defined in the elements dictionary.

test_valid_list()[source]

Should not raise any error.

class aiida.backends.tests.test_dataclasses.TestKpointsData(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the KpointsData objects.

__module__ = 'aiida.backends.tests.test_dataclasses'
test_kpoints_to_cartesian()[source]

Test how the list of kpoints is converted to cartesian coordinates

test_list()[source]

Test the method to set and retrieve a kpoint list.

test_mesh()[source]

Check the methods to set and retrieve a mesh.

test_path_wrapper_legacy()[source]

This is a clone of the test_path test but instead it goes through the new wrapper calling the deprecated legacy implementation. This tests that the wrapper maintains the same behavior of the old implementation

test_tetra_z_wrapper_legacy()[source]

This is a clone of the test_tetra_z test but instead it goes through the new wrapper calling the deprecated legacy implementation. This tests that the wrapper maintains the same behavior of the old implementation

class aiida.backends.tests.test_dataclasses.TestPymatgenFromStructureData(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the creation of pymatgen Structure and Molecule objects from StructureData.

__module__ = 'aiida.backends.tests.test_dataclasses'
get_pymatgen_version()
Returns:string with pymatgen version, None if can not import.
has_ase()
Returns:True if the ase module can be imported, False otherwise.
has_pymatgen()
Returns:True if the pymatgen module can be imported, False otherwise.
test_1()[source]

Tests the check of periodic boundary conditions.

test_2()[source]

Tests ASE -> StructureData -> pymatgen

test_3()[source]

Tests the conversion of StructureData to pymatgen’s Molecule (ASE -> StructureData -> pymatgen)

test_partial_occ_and_spin()[source]

Tests StructureData -> pymatgen, with partial occupancies and spins. This should raise a ValueError.

test_roundtrip()[source]

Tests roundtrip StructureData -> pymatgen -> StructureData (no spins)

test_roundtrip_kindnames()[source]

Tests roundtrip StructureData -> pymatgen -> StructureData (no spins, but with all kind of kind names)

test_roundtrip_partial_occ()[source]

Tests roundtrip StructureData -> pymatgen -> StructureData (with partial occupancies).

test_roundtrip_spins()[source]

Tests roundtrip StructureData -> pymatgen -> StructureData (with spins)

class aiida.backends.tests.test_dataclasses.TestSeekpathExplicitPath(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_dataclasses'
test_simple()[source]
class aiida.backends.tests.test_dataclasses.TestSeekpathPath(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_dataclasses'
test_simple()[source]
class aiida.backends.tests.test_dataclasses.TestSiteValidWeights(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests valid weight lists.

__module__ = 'aiida.backends.tests.test_dataclasses'
test_empty_list_weights()[source]

Should not accept an empty list

test_isnot_list()[source]

Should not accept a non-list, non-number weight

test_negative_value()[source]

Should not accept a negative weight

test_none()[source]

Should accept None.

test_sum_greater_one()[source]

Should not accept a sum of weights larger than one

test_sum_less_one_weights()[source]

Should accept a sum equal less than one

test_sum_one_weights()[source]

Should accept a sum equal to one

test_symbol_weight_mismatch()[source]

Should not accept a size mismatch of the symbols and weights list.

class aiida.backends.tests.test_dataclasses.TestSpglibTupleConversion(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_dataclasses'
test_aiida_roundtrip()[source]

Convert an AiiDA structure to a tuple and go back to see if we get the same results

test_complex1_to_aiida()[source]

Test conversion of a tuple to an AiiDA structure when passing also information on the kinds

test_from_aiida()[source]

Test conversion of an AiiDA structure to a spglib tuple

test_simple_to_aiida()[source]

Test conversion of a simple tuple to an AiiDA structure

class aiida.backends.tests.test_dataclasses.TestStructureData(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the creation of StructureData objects (cell and pbc).

__module__ = 'aiida.backends.tests.test_dataclasses'
has_ase()
Returns:True if the ase module can be imported, False otherwise.
has_pycifrw()
Returns:True if the PyCifRW module can be imported, False otherwise.
has_spglib()
Returns:True if the spglib module can be imported, False otherwise.
test_cell_ok_and_atoms()[source]

Test the creation of a cell and the appending of atoms

test_cell_ok_and_unknown_atoms()[source]

Test the creation of a cell and the appending of atoms, including the unknown entry.

test_get_cif()[source]

Tests the conversion to CifData

test_get_formula()[source]

Tests the generation of formula

test_get_formula_unknown()[source]

Tests the generation of formula, including unknown entry.

test_kind_1()[source]

Test the management of kinds (automatic detection of kind of simple atoms).

test_kind_1_unknown()[source]

Test the management of kinds (automatic detection of kind of simple atoms), inluding the unknown entry.

test_kind_2()[source]

Test the management of kinds (manual specification of kind name).

test_kind_2_unknown()[source]

Test the management of kinds (manual specification of kind name), including the unknown entry.

test_kind_3()[source]

Test the management of kinds (adding an atom with different mass).

test_kind_3_unknown()[source]

Test the management of kinds (adding an atom with different mass), including the unknown entry.

test_kind_4()[source]

Test the management of kind (adding an atom with different symbols or weights).

test_kind_4_unknown()[source]

Test the management of kind (adding an atom with different symbols or weights), including the unknown entry.

test_kind_5()[source]

Test the management of kinds (automatic creation of new kind if name is not specified and properties are different).

test_kind_5_bis()[source]

Test the management of kinds (automatic creation of new kind if name is not specified and properties are different). This test was failing in, e.g., commit f6a8f4b.

test_kind_5_bis_ase()[source]

Same test as test_kind_5_bis, but using ase

test_kind_5_bis_ase_unknown()[source]

Same test as test_kind_5_bis_unknown, but using ase

test_kind_5_bis_unknown()[source]

Test the management of kinds (automatic creation of new kind if name is not specified and properties are different). This test was failing in, e.g., commit f6a8f4b. This also includes the unknown entry.

test_kind_5_unknown()[source]

Test the management of kinds (automatic creation of new kind if name is not specified and properties are different), including the unknown entry.

test_kind_6()[source]

Test the returning of kinds from the string name (most of the code copied from test_kind_5()).

test_kind_6_unknown()[source]

Test the returning of kinds from the string name (most of the code copied from test_kind_5()), including the unknown entry.

test_kind_7()[source]

Test the functions returning the list of kinds, symbols, …

test_kind_7_unknown()[source]

Test the functions returning the list of kinds, symbols, … including the unknown entry.

test_kind_8()[source]

Test the ase_refine_cell() function

test_xyz_parser()[source]
class aiida.backends.tests.test_dataclasses.TestStructureDataFromAse(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the creation of Sites from/to a ASE object.

__module__ = 'aiida.backends.tests.test_dataclasses'
has_ase()
Returns:True if the ase module can be imported, False otherwise.
test_ase()[source]

Tests roundtrip ASE -> StructureData -> ASE

test_conversion_of_types_1()[source]

Tests roundtrip ASE -> StructureData -> ASE, with tags

test_conversion_of_types_2()[source]

Tests roundtrip ASE -> StructureData -> ASE, with tags, and changing the atomic masses

test_conversion_of_types_3()[source]

Tests StructureData -> ASE, with all sorts of kind names

test_conversion_of_types_4()[source]

Tests ASE -> StructureData -> ASE, in particular conversion tags / kind names

test_conversion_of_types_5()[source]

Tests ASE -> StructureData -> ASE, in particular conversion tags / kind names (subtle variation of test_conversion_of_types_4)

test_conversion_of_types_6()[source]

Tests roundtrip StructureData -> ASE -> StructureData, with tags/kind names

class aiida.backends.tests.test_dataclasses.TestStructureDataFromPymatgen(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the creation of StructureData from a pymatgen Structure and Molecule objects.

__module__ = 'aiida.backends.tests.test_dataclasses'
get_pymatgen_version()
Returns:string with pymatgen version, None if can not import.
has_pymatgen()
Returns:True if the pymatgen module can be imported, False otherwise.
test_1()[source]

Tests roundtrip pymatgen -> StructureData -> pymatgen Test’s input is derived from COD entry 9011963, processed with cif_mark_disorder (from cod-tools) and abbreviated.

test_2()[source]

Tests xyz -> pymatgen -> StructureData Input source: http://pymatgen.org/_static/Molecule.html

test_multiple_kinds_alloy()[source]

Tests that a structure with multiple sites with the same alloy symbols but different weights, get their own unique kind name

test_multiple_kinds_partial_occupancies()[source]

Tests that a structure with multiple sites with the same element but different partial occupancies, get their own unique kind name

test_partial_occ_and_spin()[source]

Tests pymatgen -> StructureData, with partial occupancies and spins. This should raise a ValueError.

class aiida.backends.tests.test_dataclasses.TestStructureDataInit(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the creation of StructureData objects (cell and pbc).

__module__ = 'aiida.backends.tests.test_dataclasses'
test_cell_ok_init()[source]

Correct cell

test_cell_wrong_size_1()[source]

Wrong cell size (not 3x3)

test_cell_wrong_size_2()[source]

Wrong cell size (not 3x3)

test_cell_zero_vector()[source]

Wrong cell (one vector has zero length)

test_cell_zero_volume()[source]

Wrong cell (volume is zero)

test_ok_pbc_1()[source]

Single pbc value

test_ok_pbc_2()[source]

One-element list

test_ok_pbc_3()[source]

Three-element list

test_volume()[source]

Check the volume calculation

test_wrong_pbc_1()[source]

Wrong pbc parameter (not bool or iterable)

test_wrong_pbc_2()[source]

Wrong pbc parameter (iterable but with wrong len)

test_wrong_pbc_3()[source]

Wrong pbc parameter (iterable but with wrong len)

class aiida.backends.tests.test_dataclasses.TestStructureDataLock(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests that the structure is locked after storage

__module__ = 'aiida.backends.tests.test_dataclasses'
test_lock()[source]

Start from a StructureData object, convert to raw and then back

class aiida.backends.tests.test_dataclasses.TestStructureDataReload(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the creation of StructureData, converting it to a raw format and converting it back.

__module__ = 'aiida.backends.tests.test_dataclasses'
test_clone()[source]

Start from a StructureData object, clone it and see if it is preserved

test_reload()[source]

Start from a StructureData object, convert to raw and then back

class aiida.backends.tests.test_dataclasses.TestTrajectoryData(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the TrajectoryData objects.

__module__ = 'aiida.backends.tests.test_dataclasses'
test_conversion_from_structurelist()[source]

Check the method to create a TrajectoryData from list of AiiDA structures.

test_conversion_to_structure()[source]

Check the methods to export a given time step to a StructureData node.

test_creation()[source]

Check the methods to set and retrieve a trajectory.

test_export_to_file()[source]

Export the band structure on a file, check if it is working

aiida.backends.tests.test_dataclasses.has_seekpath()[source]

Check if there is the seekpath dependency

Returns:True if seekpath is installed, False otherwise
aiida.backends.tests.test_dataclasses.simplify(string)[source]

Takes a string, strips spaces in each line and returns it Useful to compare strings when different versions of a code give different spaces.

aiida.backends.tests.test_dataclasses.to_list_of_lists(lofl)[source]

Converts an iterable of iterables to a list of lists, needed for some tests (e.g. when one has a tuple of lists, a list of tuples, …)

Parameters:lofl – an iterable of iterables
Returns:a list of lists

Tests for subclasses of DbImporter, DbSearchResults and DbEntry

class aiida.backends.tests.test_dbimporters.TestCodDbImporter(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test the CodDbImporter class.

__module__ = 'aiida.backends.tests.test_dbimporters'
has_pycifrw()
Returns:True if the PyCifRW module can be imported, False otherwise.
test_datatype_checks()[source]

Rather complicated, but wide-coverage test for data types, accepted and rejected by CodDbImporter._*_clause methods.

test_dbentry_creation()[source]

Tests the creation of CodEntry from CodSearchResults.

test_dbentry_to_cif_node()[source]

Tests the creation of CifData node from CodEntry.

test_query_construction_1()[source]
class aiida.backends.tests.test_dbimporters.TestMpodDbImporter(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test the MpodDbImporter class.

__module__ = 'aiida.backends.tests.test_dbimporters'
test_dbentry_creation()[source]

Tests the creation of MpodEntry from MpodSearchResults.

class aiida.backends.tests.test_dbimporters.TestNnincDbImporter(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test the UpfEntry class.

__module__ = 'aiida.backends.tests.test_dbimporters'
test_upfentry_creation()[source]

Tests the creation of NnincEntry from NnincSearchResults.

class aiida.backends.tests.test_dbimporters.TestPcodDbImporter(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test the PcodDbImporter class.

__module__ = 'aiida.backends.tests.test_dbimporters'
test_dbentry_creation()[source]

Tests the creation of PcodEntry from PcodSearchResults.

class aiida.backends.tests.test_dbimporters.TestTcodDbImporter(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test the TcodDbImporter class.

__module__ = 'aiida.backends.tests.test_dbimporters'
test_dbentry_creation()[source]

Tests the creation of TcodEntry from TcodSearchResults.

Generic tests that need the use of the DB.

class aiida.backends.tests.test_generic.TestBool(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_generic'
test_bool_conversion()[source]
test_int_conversion()[source]
class aiida.backends.tests.test_generic.TestCode(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test the Code class.

__module__ = 'aiida.backends.tests.test_generic'
test_code_local()[source]
test_remote()[source]
class aiida.backends.tests.test_nodes.AnyValue[source]

Bases: object

Helper class that compares equal to everything.

__dict__ = mappingproxy({'__module__': 'aiida.backends.tests.test_nodes', '__doc__': '\n Helper class that compares equal to everything.\n ', '__eq__': <function AnyValue.__eq__>, '__dict__': <attribute '__dict__' of 'AnyValue' objects>, '__weakref__': <attribute '__weakref__' of 'AnyValue' objects>, '__hash__': None})
__eq__(other)[source]

Return self==value.

__hash__ = None
__module__ = 'aiida.backends.tests.test_nodes'
__weakref__

list of weak references to the object (if defined)

class aiida.backends.tests.test_nodes.TestNodeBasic(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

These tests check the basic features of nodes (setting of attributes, copying of files, …)

__module__ = 'aiida.backends.tests.test_nodes'
boolval = True
dictval = {'emptydict': {}, 'num': 3, 'recursive': {'a': 1, 'b': True, 'c': 1.2, 'd': [1, 2, None], 'e': {'x': None, 'xx': {}, 'yy': [], 'z': 'z'}}, 'something': 'else'}
emptydict = {}
emptylist = []
floatval = 4.56
intval = 123
listval = [1, 's', True, None]
stringval = 'aaaa'
test_attr_after_storing()[source]
test_attr_and_extras_multikey()[source]

Multiple nodes with the same key. This should not be a problem

I test only extras because the two tables are formally identical

test_attr_before_storing()[source]
test_attr_listing()[source]

Checks that the list of attributes and extras is ok.

test_attr_with_reload()[source]
test_attribute_mutability()[source]

Attributes of a node should be immutable after storing, unless the stored_check is disabled in the call

test_attributes_on_clone()[source]
test_basetype_as_attr()[source]

Test that setting a basetype as an attribute works transparently

test_basetype_as_extra()[source]

Test that setting a basetype as an attribute works transparently

test_code_description()[source]

This test checks that the code description is retrieved correctly when the code is searched with its id and label.

test_code_loading_from_string()[source]

Checks that the method Code.get_from_string works correctly.

test_code_loading_using_get()[source]

Checks that the method Code.get(pk) works correctly.

test_comments()[source]
test_delete_extras()[source]

Checks the ability of deleting extras, also when they are dictionaries or lists.

test_extra_with_reload()[source]
test_files()[source]
test_folders()[source]

Similar as test_files, but I manipulate a tree of folders

test_get_attrs_after_storing()[source]
test_get_attrs_before_storing()[source]
test_get_extras_with_default()[source]
test_list_for_plugin()[source]

This test checks the Code.list_for_plugin()

test_load_node()[source]

Tests the load node functionality

test_load_unknown_data_type()[source]

Test that the loader will choose a common data ancestor for an unknown data type. For the case where, e.g., the user doesn’t have the necessary plugin.

test_replace_extras_1()[source]

Checks the ability of replacing extras, removing the subkeys also when these are dictionaries or lists.

test_store_object()[source]

Trying to set objects as attributes should fail, because they are not json-serializable.

test_uuid_uniquess()[source]

A uniqueness constraint on the UUID column of the Node model should prevent multiple nodes with identical UUID

class aiida.backends.tests.test_nodes.TestNodeCopyDeepcopy(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test that calling copy and deepcopy on a Node does the right thing.

__module__ = 'aiida.backends.tests.test_nodes'
test_copy_not_supported()[source]

Copying a base Node instance is not supported.

test_deepcopy_not_supported()[source]

Deep copying a base Node instance is not supported.

class aiida.backends.tests.test_nodes.TestNodeDeletion(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_nodes'
_check_existence(uuids_check_existence, uuids_check_deleted)[source]

I get 2 lists of uuids

Parameters:
  • uuids_check_existence – The list of uuids that have to exist
  • uuids_check_deleted – The list of uuids that should not exist, I check that NotExistent is raised.
_create_calls_n_returns_graph()[source]

Creates a complicated graph with a master with 1 inputs, 2 slaves of it also using that input and an additional 1, producing output that is either returned or not returned by the master. Master also creates one nodes. This allows to check whether the delete_nodes command works as anticipated.

test_delete_called_but_not_caller()[source]

Check that deleting a ProcessNode that was called by another ProcessNode which won’t be deleted works, even though it will raise a warning

test_deletion_no_calls_no_returns()[source]

Checking the case where I don’t follow calls and also not return links for deletion

test_deletion_no_calls_with_returns()[source]

Checking the case where I follow returns and not calls for deletion

test_deletion_non_existing_pk()[source]

Verify that passing a non-existing pk should not raise.

test_deletion_simple()[source]

I’m setting up a sequence of nodes connected by data provenance links. Testing whether I will delete the right ones.

test_deletion_with_calls_no_returns()[source]

Checking the case where I follow calls and not return links for deletion

test_deletion_with_calls_with_returns()[source]

Checking the case where I follow calls and return links for deletion

test_deletion_with_returns_n_loops()[source]

Setting up a simple loop, to check that the following doesn’t go bananas.

class aiida.backends.tests.test_nodes.TestNodeHashing(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests the functionality of hashing a node

__module__ = 'aiida.backends.tests.test_nodes'
static create_folderdata_with_empty_file()[source]
static create_folderdata_with_empty_folder()[source]
static create_simple_node(a, b=0, c=0)[source]
test_folder_file_different()[source]
test_node_uuid_hashing_for_querybuidler()[source]

QueryBuilder results should be reusable and shouldn’t brake hashing.

test_updatable_attributes()[source]

Tests that updatable attributes are ignored.

class aiida.backends.tests.test_nodes.TestNodeIsStorable(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test if one can store specific Node subclasses, and that Node and ProcessType are not storable, intead.

__module__ = 'aiida.backends.tests.test_nodes'
test_storable_unstorable()[source]

Test storability of Nodes

class aiida.backends.tests.test_nodes.TestQueryWithAiidaObjects(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test if queries work properly also with aiida.orm.Node classes instead of aiida.backends.djsite.db.models.DbNode objects.

__module__ = 'aiida.backends.tests.test_nodes'
test_with_subclasses()[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_nodes'

Test the proper functionality of the links cache, with different scenarios.

test_calculation_load()[source]
test_check_single_calc_source()[source]

Each data node can only have one input calculation

It is possible to store links between nodes even if they are unstored these links are cached.

Cannot have two CREATE links for the same node.

Test that the link_type parameter in get_incoming and get_outgoing only returns those nodes with the correct link type for stored nodes

test_store_with_unstored_parents()[source]

I want to check that if parents are unstored I cannot store

test_storeall_with_unstored_grandparents()[source]

I want to check that if grandparents are unstored I cannot store_all

class aiida.backends.tests.test_nodes.TestTransitiveNoLoops(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test the transitive closure functionality

__module__ = 'aiida.backends.tests.test_nodes'
test_loop_not_allowed()[source]
class aiida.backends.tests.test_nodes.TestTypes(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Generic test class to test types

__module__ = 'aiida.backends.tests.test_nodes'
test_uuid_type()[source]

Checking whether the UUID is returned as a string. In old implementations it was returned as uuid type

class aiida.backends.tests.test_plugin_loader.TestExistingPlugins(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Test the get_entry_points function and the plugin Factories.

Will fail when:

  • If get_entry_points returns something other than a list
  • Any of the plugins, distributed with aiida or installed from external plugin repositories, fail to load
__module__ = 'aiida.backends.tests.test_plugin_loader'
test_existing_calculations()[source]

Test listing all preinstalled calculations.

test_existing_data()[source]

Test listing all preinstalled data classes.

test_existing_dbimporters()[source]

Test listing all preinstalled dbimporter plugins.

test_existing_parsers()[source]

Test listing all preinstalled parsers.

test_existing_schedulers()[source]

Test listing all preinstalled schedulers.

test_existing_transports()[source]

Test listing all preinstalled transports.

test_existing_workflows()[source]

Test listing all preinstalled workflows.

Tests for the QueryBuilder.

class aiida.backends.tests.test_query.QueryBuilderJoinsTests(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_query'
test_joins1()[source]
test_joins2()[source]
test_joins3_user_group()[source]
test_joins_group_node()[source]

This test checks that the querying for the nodes that belong to a group works correctly (using QueryBuilder). This is important for the Django backend with the use of aldjemy for the Django to SQLA schema translation. Since this is not backend specific test (even if it is mainly used to test the querying of Django backend with QueryBuilder), we keep it at the general tests (ran by both backends).

class aiida.backends.tests.test_query.QueryBuilderLimitOffsetsTest(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_query'
test_ordering_limits_offsets_of_results_general()[source]
class aiida.backends.tests.test_query.QueryBuilderPath(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_query'
test_query_path()[source]
class aiida.backends.tests.test_query.TestAttributes(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_query'
test_attribute_existence()[source]
test_attribute_type()[source]
class aiida.backends.tests.test_query.TestConsistency(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_query'
test_create_node_and_query()[source]

Testing whether creating nodes within a iterall iteration changes the results.

test_len_results()[source]

Test whether the len of results matches the count returned. See also https://github.com/aiidateam/aiida-core/issues/1600 SQLAlchemy has a deduplication strategy that leads to strange behavior, tested against here

class aiida.backends.tests.test_query.TestDoubleStar(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

In this test class we check if QueryBuilder returns the correct results when double star is provided as projection.

__module__ = 'aiida.backends.tests.test_query'
test_statistics_default_class()[source]
class aiida.backends.tests.test_query.TestManager(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_query'
test_statistics()[source]

Test if the statistics query works properly.

I try to implement it in a way that does not depend on the past state.

test_statistics_default_class()[source]

Test if the statistics query works properly.

I try to implement it in a way that does not depend on the past state.

class aiida.backends.tests.test_query.TestQueryBuilder(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_query'
setUp()[source]

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

test_append_validation()[source]
test_list_behavior()[source]
test_operators_eq_lt_gt()[source]
test_ormclass_type_classification()[source]

This tests the classifications of the QueryBuilder

test_process_query()[source]

Test querying for a process class.

test_process_type_classification()[source]

This tests the classifications of the QueryBuilder

test_simple_query_1()[source]

Testing a simple query

test_simple_query_2()[source]
test_subclassing()[source]
test_tags()[source]
class aiida.backends.tests.test_query.TestQueryBuilderCornerCases(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

In this class corner cases of QueryBuilder are added.

__module__ = 'aiida.backends.tests.test_query'
test_computer_json()[source]

In this test we check the correct behavior of QueryBuilder when retrieving the _metadata with no content. Note that they are in JSON format in both backends. Forcing the decoding of a None value leads to an exception (this was the case under Django).

class aiida.backends.tests.test_query.TestQueryHelp(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.test_query'
test_queryhelp()[source]

Here I test the queryhelp by seeing whether results are the same as using the append method. I also check passing of tuples.

Unittests for REST API.

class aiida.backends.tests.test_restapi.RESTApiTestCase(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Setup of the tests for the AiiDA RESTful-api

_LIMIT_DEFAULT = 400
_PERPAGE_DEFAULT = 20
__module__ = 'aiida.backends.tests.test_restapi'
_dummy_data = {}
_url_prefix = '/api/v3'
compare_extra_response_data(node_type, url, response, uuid=None)[source]

In url response, we pass some extra information/data along with the node results. e.g. url method, node_type, path, pk, query_string, url, url_root, etc.

Parameters:
  • node_type – url requested fot the type of the node
  • url – web url
  • response – url response
  • uuid – url requested for the node pk
get_dummy_data()[source]
get_url_prefix()[source]
classmethod process_dummy_data()[source]

This functions prepare atomic chunks of typical responses from the RESTapi and puts them into class attributes

process_test(entity_type, url, full_list=False, empty_list=False, expected_list_ids=None, expected_range=None, expected_errormsg=None, uuid=None, result_node_type=None, result_name=None)[source]

Check whether response matches expected values.

Parameters:
  • entity_type – url requested fot the type of the node
  • url – web url
  • full_list – if url is requested to get full list
  • empty_list – if the response list is empty
  • expected_list_ids – list of expected ids from data
  • expected_range – [start, stop] range of expected ids from data
  • expected_errormsg – expected error message in response
  • uuid – url requested for the node pk
  • result_node_type – node type in response data
  • result_name – result name in response e.g. inputs, outputs
classmethod setUpClass(*args, **kwargs)[source]

Basides the standard setup we need to add few more objects in the database to be able to explore different requests/filters/orderings etc.

split_path(url)[source]

Split the url with “?” to get url path and it’s parameters :param url: Web url :return: url path and url parameters

class aiida.backends.tests.test_restapi.RESTApiTestSuite(methodName='runTest')[source]

Bases: aiida.backends.tests.test_restapi.RESTApiTestCase

Define unittests for rest api

__module__ = 'aiida.backends.tests.test_restapi'
test_calcfunction_retrieved_inputs()[source]

Check that the given calcfunction does not have retrieved_inputs

test_calcfunction_retrieved_outputs()[source]

Check that the given calcfunction does not have retrieved_outputs

test_calculation_attributes()[source]

Get list of calculation attributes

test_calculation_attributes_alist_filter()[source]

Get list of calculation attributes with filter alist

test_calculation_attributes_nalist_filter()[source]

Get list of calculation attributes with filter nalist

test_calculation_input_filters()[source]

Get filtered inputs list for given calculations

test_calculation_inputs()[source]

Get the list of give calculation inputs

test_calculation_iotree()[source]

Get filtered inputs list for given calculations

test_calculation_retrieved_inputs()[source]

Get the list of given calculation retrieved_inputs

test_calculation_retrieved_outputs()[source]

Get the list of given calculation retrieved_outputs

test_calculations_details()[source]

Requests the details of single calculation

test_calculations_list()[source]

Get the full list of calculations from database

test_calculations_list_limit_offset()[source]

Get the list of calculations from database using limit and offset parameter. It should return the no of rows specified in limit from database starting from the no. specified in offset

test_cif()[source]

Test download of cif file

test_comp_orderby_scheduler_ascsign()[source]

Returns the computers list ordered by “+scheduler_type” in ascending order

test_complist_pagelimitoffset_perpage()[source]

If we use the page, limit, offset and perpage at same time, it would return the error message.

test_computers_details()[source]

Requests the details of single computer

test_computers_filter_hostname()[source]

Add filter for the hostname of computer and get the filtered computer list

test_computers_filter_id1()[source]

Add filter on the id of computer and get the filtered computer list (e.g. id=1)

test_computers_filter_id2()[source]

Add filter on the id of computer and get the filtered computer list (e.g. id > 2)

test_computers_filter_mixed1()[source]

Add filter for the hostname and id of computer and get the filtered computer list

test_computers_filter_mixed2()[source]

Add filter for the id, hostname and transport_type of the computer and get the filtered computer list

test_computers_filter_name()[source]

Add filter for the name of computer and get the filtered computer list

test_computers_filter_pk()[source]

Add filter on the id of computer and get the filtered computer list (e.g. id=1)

test_computers_filter_transport_type()[source]

Add filter for the transport_type of computer and get the filtered computer list

test_computers_list()[source]

Get the full list of computers from database

test_computers_list_limit_offset()[source]

Get the list of computers from database using limit and offset parameter. It should return the no of rows specified in limit from database starting from the no. specified in offset

test_computers_list_limit_offset_perpage()[source]

If we pass the limit, offset and perpage at same time, it would return the error message.

test_computers_list_limit_only()[source]

Get the list of computers from database using limit parameter. It should return the no of rows specified in limit from database.

test_computers_list_offset_only()[source]

Get the list of computers from database using offset parameter It should return all the rows from database starting from the no. specified in offset

test_computers_list_page_default()[source]

it returns the no. of rows defined as default perpage option from database.

no.of pages = total no. of computers in database / perpage “/page” acts as “/page/1?perpage=default_value”

test_computers_list_page_limit_offset()[source]

If we use the page, limit and offset at same time, it would return the error message.

test_computers_list_page_perpage()[source]

no.of pages = total no. of computers in database / perpage Using this formula it returns the no. of rows for requested page

test_computers_list_page_perpage_exceed()[source]

no.of pages = total no. of computers in database / perpage

If we request the page which exceeds the total no. of pages then it would return the error message.

test_computers_mixed1()[source]

url parameters: id, limit and offset

test_computers_mixed2()[source]

url parameters: id, page, perpage

test_computers_mixed3()[source]

url parameters: id, transport_type, orderby

test_computers_orderby_id_asc()[source]

Returns the computers list ordered by “id” in ascending order

test_computers_orderby_id_asc_sign()[source]

Returns the computers list ordered by “+id” in ascending order

test_computers_orderby_id_desc()[source]

Returns the computers list ordered by “id” in descending order

test_computers_orderby_mixed1()[source]

Returns the computers list first order by “transport_type” in ascending order and if it is having same transport_type, order it by “id”

test_computers_orderby_mixed2()[source]

Returns the computers list first order by “scheduler_type” in descending order and if it is having same scheduler_type, order it by “name”

test_computers_orderby_mixed3()[source]

Returns the computers list first order by “scheduler_type” in ascending order and if it is having same scheduler_type, order it by “hostname” descending order

Response:: test4 slurm test3 slurm test2 torque test1 pbspro localhost pbspro ========== Expected:: test1 pbspro localhost pbspro test4 slurm test3 slurm test2 torque test1 test4

RESTApiTestCase.process_test(self, “computers”,
“/computers?orderby=+scheduler_type, -hostname”, expected_list_ids=[1,0,4,3,2])
test_computers_orderby_name_asc()[source]

Returns the computers list ordered by “name” in ascending order

test_computers_orderby_name_asc_sign()[source]

Returns the computers list ordered by “+name” in ascending order

test_computers_orderby_name_desc()[source]

Returns the computers list ordered by “name” in descending order

test_computers_orderby_scheduler_type_asc()[source]

Returns the computers list ordered by “scheduler_type” in ascending order

test_computers_orderby_schedulertype_desc()[source]

Returns the computers list ordered by “scheduler_type” in descending order

test_computers_unknown_param()[source]

url parameters: id, limit and offset

from aiida.common.exceptions import InputValidationError RESTApiTestCase.node_exception(self, “/computers?aa=bb&id=2”, InputValidationError)

test_node_types()[source]

Test the rest api call to get list of available node types

test_schema()[source]

test schema

test_structure_visualization()[source]

Get the list of give calculation inputs

test_visualization()[source]

Get the list of given calculation inputs

test_xsf_visualization()[source]

Get the list of given calculation inputs