aiida.backends.tests.common package

Submodules

Tests for the Archive class.

class aiida.backends.tests.common.test_archive.TestCommonArchive(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests for the aiida.common.archive.Archive class.

__module__ = 'aiida.backends.tests.common.test_archive'
test_context_required()[source]

Verify that accessing a property of an Archive outside of a context manager raises.

test_version_format()[source]

Verify that version_format return the correct archive format version.

aiida.backends.tests.common.test_archive.get_archive_file(archive)[source]

Return the absolute path of the archive file used for testing purposes. The expected path for these files:

aiida.backends.tests.export_import_test_files.migrate
Parameters:archive – the relative filename of the archive
Returns:absolute filepath of the archive test file

Tests for the extended dictionary classes.

class aiida.backends.tests.common.test_extendeddicts.TestAttributeDictAccess(methodName='runTest')[source]

Bases: unittest.case.TestCase

Try to access the dictionary elements in various ways, copying (shallow and deep), check raised exceptions.

__module__ = 'aiida.backends.tests.common.test_extendeddicts'
test_access_attr_to_dict()[source]

Test attribute to dictionary.

test_access_dict_to_attr()[source]

Test dictionary to attribute.

test_access_nonexisting_asattr()[source]

Test non-existing attribute.

test_access_nonexisting_askey()[source]

Test non-existing attribute as key.

test_copy()[source]

Test copying.

test_deepcopy1()[source]

Test deep copying.

test_del_nonexisting_asattr()[source]

Test deleting non-existing attribute.

test_del_nonexisting_askey()[source]

Test deleting non-existing attribute as key.

test_delete_after_copy()[source]

Test deleting after copying.

test_shallowcopy1()[source]

Test shallow copying.

test_shallowcopy2()[source]

Test shallow copying.

test_shallowcopy3()[source]

Test shallow copying.

class aiida.backends.tests.common.test_extendeddicts.TestAttributeDictNested(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test the functionality of nested AttributeDict classes.

__module__ = 'aiida.backends.tests.common.test_extendeddicts'
test_comparison()[source]

Test dictionary comparison.

test_nested()[source]

Test nested dictionary.

test_nested_deepcopy()[source]

Test nested deepcopy.

class aiida.backends.tests.common.test_extendeddicts.TestAttributeDictSerialize(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test serialization/deserialization (with json, pickle, …)

__module__ = 'aiida.backends.tests.common.test_extendeddicts'
test_json()[source]

Test loading and dumping from json.

test_json_recursive()[source]

Test loading and dumping from json recursively.

test_pickle()[source]

Test pickling.

test_pickle_recursive()[source]

Test pickling recursively.

class aiida.backends.tests.common.test_extendeddicts.TestDFAD(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test for the default fields attribute dictionary.

__module__ = 'aiida.backends.tests.common.test_extendeddicts'
test_class_attribute()[source]

I test that the get_default_fields() is working as a class method, so I don’t need to instantiate the class to get the list.

test_insertion_and_retrieval()[source]

Test insertion and retrieval.

test_keylist_method()[source]

Test keylist retrieval.

test_validation()[source]

Test validation.

class aiida.backends.tests.common.test_extendeddicts.TestDFADExample[source]

Bases: aiida.common.extendeddicts.DefaultFieldsAttributeDict

An example class that has ‘alpha’, ‘beta’ and ‘gamma’ as default keys.

__module__ = 'aiida.backends.tests.common.test_extendeddicts'
_default_fields = ('alpha', 'beta', 'gamma')
static validate_alpha(value)[source]

Validate a value.

class aiida.backends.tests.common.test_extendeddicts.TestFFAD(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test for the fixed fields attribute dictionary.

__module__ = 'aiida.backends.tests.common.test_extendeddicts'
test_class_attribute()[source]

I test that the get_valid_fields() is working as a class method, so I don’t need to instantiate the class to get the list.

test_insertion()[source]

Test insertion.

test_insertion_on_init()[source]

Test insertion in constructor.

test_pickle()[source]

Note: pickle works here because self._valid_fields is defined at the class level!

class aiida.backends.tests.common.test_extendeddicts.TestFFADExample(init=None)[source]

Bases: aiida.common.extendeddicts.FixedFieldsAttributeDict

An example class that accepts only the ‘alpha’, ‘beta’ and ‘gamma’ keys/attributes.

__module__ = 'aiida.backends.tests.common.test_extendeddicts'
_valid_fields = ('alpha', 'beta', 'gamma')

Tests for the folder class

class aiida.backends.tests.common.test_folders.FoldersTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for the Folder class.

__module__ = 'aiida.backends.tests.common.test_folders'
static test_create_file_from_filelike_py2()[source]

Test aiida.common.folders.Folder.create_file_from_filelike for python 2.

test_create_file_from_filelike_py3(**kwargs)[source]

Test aiida.common.folders.Folder.create_file_from_filelike for python 3.

test_get_abs_path_without_limit()[source]

Check that the absolute path function can get an absolute path

classmethod test_unicode(**kwargs)[source]

Check that there are no exceptions raised when using unicode folders.

aiida.backends.tests.common.test_folders.fs_encoding_is_utf8()[source]
Returns:True if the current filesystem encoding is set to UTF-8

Unittests for aiida.common.hashing:make_hash with hardcoded hash values

class aiida.backends.tests.common.test_hashing.MakeHashTest(methodName='runTest')[source]

Bases: unittest2.case.TestCase

Tests for the make_hash function.

__module__ = 'aiida.backends.tests.common.test_hashing'
test_builtin_types()[source]
test_bytes()[source]
test_collection_with_dicts()[source]
test_collection_with_odicts()[source]
test_collection_with_ordered_sets()[source]
test_collection_with_unordered_sets()[source]
test_collisions_with_nested_objs()[source]
test_datetime()[source]
test_folder()[source]
test_nested_collections()[source]
test_numpy_arrays()[source]
test_numpy_types()[source]
test_unhashable_type()[source]
test_unicode_string()[source]
test_uuid()[source]
class aiida.backends.tests.common.test_hashing.PasswordFunctions(methodName='runTest')[source]

Bases: unittest2.case.TestCase

Tests for the password hashing functions.

__module__ = 'aiida.backends.tests.common.test_hashing'
test_is_usable()[source]
test_unusable_password()[source]
class aiida.backends.tests.common.test_hashing.TruncationTest(methodName='runTest')[source]

Bases: unittest2.case.TestCase

Tests for the truncate_* methods

__module__ = 'aiida.backends.tests.common.test_hashing'
test_inf()[source]
test_nan()[source]
test_subnormal()[source]

Tests for the logging module.

class aiida.backends.tests.common.test_logging.TestLogger(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test global python logging module.

__module__ = 'aiida.backends.tests.common.test_logging'
test_logger()[source]

The python logging module is configured with a DbLogHandler upon runtime, but we do not want any fired log messages to crash when they reach the handler and no database is set yet

Serialization tests

class aiida.backends.tests.common.test_serialize.TestSerialize(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.tests.common.test_serialize'
test_serialize_computer_round_trip()[source]

Test you can serialize and deserialize a computer

test_serialize_group()[source]

Test that serialization and deserialization of Groups works. Also make sure that the serialized data is json-serializable

test_serialize_group_round_trip()[source]

Test you can serialize and deserialize a group

test_serialize_node_round_trip()[source]

Test you can serialize and deserialize a node

test_serialize_round_trip()[source]

Test the serialization of a dictionary with Nodes in various data structure Also make sure that the serialized data is json-serializable

test_serialize_unstored_computer()[source]

Test that you can’t serialize an unstored node

test_serialize_unstored_group()[source]

Test that you can’t serialize an unstored group

test_serialize_unstored_node()[source]

Test that you can’t serialize an unstored node

Tests for the timezone utility module.

class aiida.backends.tests.common.test_timezone.TimezoneTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for the timezone utility module.

__module__ = 'aiida.backends.tests.common.test_timezone'
test_timezone_now()[source]

Test timezone.now function.

Tests for the aiida.common.utils functionality

class aiida.backends.tests.common.test_utils.PrettifierTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for the Prettifier class methods.

__module__ = 'aiida.backends.tests.common.test_utils'
test_prettifier()[source]

Check that the prettified strings work as expected for a number of different labels and different codes that should show them

class aiida.backends.tests.common.test_utils.SqlStringMatchTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

” Test the functions to convert SQL to regex patterns

__module__ = 'aiida.backends.tests.common.test_utils'
test_patterns()[source]

” Test complex patterns to see if the logic of conversion is correct

class aiida.backends.tests.common.test_utils.UniqueTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Tests for the get_unique_filename function.

__module__ = 'aiida.backends.tests.common.test_utils'
array_counter()[source]
seq = -1
test_ask_backup_question()[source]

This method checks that the combined use of query_string and query_yes_no by the ask_backup_question is done as expected.

test_query_string()[source]

This method tests that the query_string method behaves as expected.

test_query_yes_no()[source]

This method tests the query_yes_no method behaves as expected. To perform this, a lambda function is used to simulate the user input.

test_unique_1()[source]
test_unique_2()[source]
test_unique_3()[source]
test_unique_4()[source]