aiida.backends.sqlalchemy.tests package¶
Subpackages¶
Submodules¶
Generic tests that need the be specific to sqlalchemy
-
class
aiida.backends.sqlalchemy.tests.generic.
TestComputer
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
Test the Computer class.
-
__module__
= 'aiida.backends.sqlalchemy.tests.generic'¶
-
-
class
aiida.backends.sqlalchemy.tests.generic.
TestDbExtrasSqla
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
Characterized functions
-
__module__
= 'aiida.backends.sqlalchemy.tests.generic'¶
-
-
class
aiida.backends.sqlalchemy.tests.generic.
TestGroupNoOrmSQLA
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
These tests check that the group node addition works ok when the skip_orm=True flag is used
-
__module__
= 'aiida.backends.sqlalchemy.tests.generic'¶
-
-
class
aiida.backends.sqlalchemy.tests.generic.
TestGroupsSqla
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
Characterized functions
-
__module__
= 'aiida.backends.sqlalchemy.tests.generic'¶
-
-
class
aiida.backends.sqlalchemy.tests.migrations.
TestMigrationApplicationSQLA
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
This class contains tests for the migration mechanism of SQLAlchemy called alembic. It checks if the migrations can be applied and removed correctly.
-
__module__
= 'aiida.backends.sqlalchemy.tests.migrations'¶
-
alembic_dpath
= None¶
-
migr_method_dir_path
= None¶
-
classmethod
setUpClass
(*args, **kwargs)[source]¶ Hook method for setting up class fixture before running tests in the class.
-
test_migrations_forward_backward
()[source]¶ This is a very broad test that checks that the migration mechanism works. More specifically, it checks that:
- Alembic database migrations to specific versions work (upgrade & downgrade) - The methods that are checking the database schema version and perform the migration procedure to the last version work correctly.
-
-
class
aiida.backends.sqlalchemy.tests.migrations.
TestMigrationSchemaVsModelsSchema
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
This class checks that the schema that results from a migration is the same generated by the models. This is important since migrations are frequently written by hand or extended manually and we have to ensure that the final result is what is conceived in the SQLA models.
-
__module__
= 'aiida.backends.sqlalchemy.tests.migrations'¶
-
alembic_cfg_left
= None¶
-
alembic_dpath
= None¶
-
db_url_left
= None¶
-
db_url_right
= None¶
-
migr_method_dir_path
= None¶
-
Tests for nodes, attributes and links
-
class
aiida.backends.sqlalchemy.tests.nodes.
TestNodeBasicSQLA
(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.sqlalchemy.tests.nodes'¶
-
-
class
aiida.backends.sqlalchemy.tests.nodes.
TestTransitiveClosureDeletionSQLA
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
Test the creation of the transitive closure table
-
__module__
= 'aiida.backends.sqlalchemy.tests.nodes'¶
-
-
class
aiida.backends.sqlalchemy.tests.query.
QueryBuilderLimitOffsetsTestSQLA
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
-
__module__
= 'aiida.backends.sqlalchemy.tests.query'¶
-
-
class
aiida.backends.sqlalchemy.tests.query.
TestQueryBuilderSQLA
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
-
__module__
= 'aiida.backends.sqlalchemy.tests.query'¶
-
-
class
aiida.backends.sqlalchemy.tests.schema.
TestRelationshipsSQLA
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
Class of tests concerning the schema and the correct implementation of relationships within the AiiDA ORM
The genereal naming convention is the following: 1)tests on one-to-many relationships: test_<Parent>_<child> (Parent class is capitalized) 2)tests on many-to-many relationships: test_<peer>_<peer> (none is capitalized)
-
__module__
= 'aiida.backends.sqlalchemy.tests.schema'¶
-
test_User_node_1
()[source]¶ Test that when a user and a node having that user are created, storing NODE induces storage of the USER
Assert the correct storage of user and node
-
test_User_node_2
()[source]¶ Test that when a user and a node having that user are created, storing USER does NOT induce storage of the NODE
Assert the correct storage of user and node
-
test_User_node_3
()[source]¶ Test that when a user and two nodes having that user are created, storing only ONE NODE induces storage of that node, of the user but not of the other node
Assert the correct storage of the user and node. Assert the non-storage of the other node
-
test_User_node_4
()[source]¶ Test that when several nodes are created with the same user and each of them is assigned to the same name, storage of last node object associated to that node does not trigger storage of all objects.
Assert the correct storage of the user and node. Assert the non-storage of the other nodes
-
Testing Session possible problems.
-
class
aiida.backends.sqlalchemy.tests.session.
TestSessionSqla
(methodName='runTest')[source]¶ Bases:
aiida.backends.testbase.AiidaTestCase
The following tests check that the session works as expected in some problematic examples. When a session is initialized with expire_on_commit=False allows more permissive behaviour since committed objects that remain in the session do not need refresh. The opposite happens when expire_on_commit=True.
Moreover, 2 ways of storing objects are tested, i.e. adding the objects manually to the session and committing it & by using the build-in store method of the ORM objects.
-
__module__
= 'aiida.backends.sqlalchemy.tests.session'¶
-
test_session_update_and_expiration_1
()[source]¶ expire_on_commit=True & adding manually and committing computer and code objects.
-
test_session_update_and_expiration_2
()[source]¶ expire_on_commit=True & committing computer and code objects with their built-in store function.
-
test_session_update_and_expiration_3
()[source]¶ expire_on_commit=False & adding manually and committing computer and code objects.
-
test_session_update_and_expiration_4
()[source]¶ expire_on_commit=False & committing computer and code objects with their built-in store function.
-
test_session_wfdata
()[source]¶ This test checks that the aiida.backends.sqlalchemy.models.workflow.DbWorkflowData#set_value method works as expected. There were problems with the DbNode object that was added as a value to a DbWorkflowData object. If there was an older version of the dbnode in the session than the one given to to the DbWorkflowData#set_value then there was a collision in the session and SQLA identity map.
-
-
class
aiida.backends.sqlalchemy.tests.testbase.
SqlAlchemyTests
[source]¶ Bases:
aiida.backends.testimplbase.AiidaTestImplementation
-
__abstractmethods__
= frozenset([])¶
-
__module__
= 'aiida.backends.sqlalchemy.tests.testbase'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
connection
= None¶
-
drop_all
= False¶
-
setUpClass_method
()[source]¶ This class prepares the database (cleans it up and installs some basic entries). You have also to set a self.computer and a self.user_email as explained in the docstring of the AiidaTestImplemention docstring.
-
tearDownClass_method
()[source]¶ This class implements the tear down methods (e.g. cleans up the DB).
-
test_session
= None¶
-
In this file various data management functions, needed for the SQLA test, are added. They are “heavily inspired” by the sqlalchemy_utils.functions.database (SQLAlchemy-Utils package).
However, they were corrected to work properly with a SQlAlchemy and PostgreSQL. The main problem of the SQLAlchemy-Utils that were rewritten was that they were not properly disposing the (SQLA) engine, resulting to error messages from PostgreSQL.
-
aiida.backends.sqlalchemy.tests.utils.
create_database
(url, encoding='utf8')[source]¶ Issue the appropriate CREATE DATABASE statement.
This is a modification of sqlalchemy_utils.functions.database.create_database since the latter one did not correctly work with SQLAlchemy and PostgreSQL.
Parameters: - url – A SQLAlchemy engine URL.
- encoding – The encoding to create the database as.
It currently supports only PostgreSQL and the psycopg2 driver.
-
aiida.backends.sqlalchemy.tests.utils.
database_exists
(url)[source]¶ Check if a database exists.
This is a modification of sqlalchemy_utils.functions.database.database_exists since the latter one did not correctly work with SQLAlchemy and PostgreSQL.
Parameters: url – A SQLAlchemy engine URL. Performs backend-specific testing to quickly determine if a database exists on the server.