aiida.backends.tests.common package

Submodules

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.

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.

test_recursive_attribute_dict()[source]

Test that all nested dictionaries are also recursively turned into AttributeDict instances.

test_shallow_copy()[source]

Test shallow copying using either the copy method of the dict class or the copy module.

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(dictionary=None)[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()[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()[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.CheckDBRoundTrip(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Check that the hash does not change after a roundtrip via the DB. Note that this class must inherit from AiiDATestCase since it’s working with the DB.

__module__ = 'aiida.backends.tests.common.test_hashing'
test_attribute_storing()[source]

I test that when storing different types of data as attributes (using a dict), the hash is the same before and after storing.

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

Bases: unittest.case.TestCase

Tests for the float_to_text methods

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

Bases: unittest.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_types()[source]
test_unhashable_type()[source]
test_unicode_string()[source]
test_uuid()[source]

Tests for the lang module.

class aiida.backends.tests.common.test_lang.Protected[source]

Bases: object

Class to test the protected decorator.

__dict__ = mappingproxy({'__module__': 'aiida.backends.tests.common.test_lang', '__doc__': 'Class to test the protected decorator.', 'member_internal': <function Protected.member_internal>, 'member_unprotected': <function Protected.member_unprotected>, 'member_protected_unchecked': <function Protected.member_protected_unchecked>, 'member_protected_checked': <function Protected.member_protected_checked>, 'property_correct_order': <property object>, '__dict__': <attribute '__dict__' of 'Protected' objects>, '__weakref__': <attribute '__weakref__' of 'Protected' objects>})
__module__ = 'aiida.backends.tests.common.test_lang'
__weakref__

list of weak references to the object (if defined)

member_internal()[source]

Class method that is allowed to call the protected methods.

member_protected_checked()[source]

Decorated method but without check - cannot be called outside scope.

member_protected_unchecked()[source]

Decorated method but without check - can be called outside scope.

member_unprotected()[source]

Simple unproctected method.

property property_correct_order

Decorated property but without check - cannot be called outside scope.

class aiida.backends.tests.common.test_lang.TestProtectedDecorator(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests for the protected() decorator.

__module__ = 'aiida.backends.tests.common.test_lang'
test_free_function()[source]

Decorating a free function should raise.

test_internal()[source]

Calling protected internally from a public class method should work.

test_property_incorrect_order()[source]

The protected decorator should raise if applied before the property decorator.

test_protected_checked()[source]

Test that calling a checked protected class method raises.

test_protected_property_correct_order()[source]

Test that calling a checked protected property raises.

test_protected_unchecked()[source]

Test that calling an unchecked protected class method is allowed.

test_unprotected()[source]

Test that calling unprotected class method is allowed.

Tests for the links utilities.

class aiida.backends.tests.common.test_links.TestValidateLinkLabel(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

Tests for validate_link_label function.

__module__ = 'aiida.backends.tests.common.test_links'

Test that illegal link labels will raise a ValueError.

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

Tests for the YAML serializer and deserializer.

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

Regression test for #3092.

The yaml mapping constructor in aiida.orm.utils.serialize was not properly “deeply” reconstructing nested mappings, causing a mix of attribute dictionaries and normal dictionaries to lose information in a round-trip.

If a nested AttributeDict contained a normal dictionary, the content of the latter would be lost during the deserialization, despite the information being present in the serialized yaml dump.

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]