Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Plugin fixtures #716

Merged
merged 22 commits into from
Oct 20, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion .travis-data/test_plugin_testcase.py
@@ -1,5 +1,11 @@
"""Test the plugin test case"""
"""
Test the plugin test case

This must be in a separate file because it would clash with other tests,
Since the dbenv gets loaded on the temporary profile.
"""
import os
import unittest

from aiida.utils.fixtures import PluginTestCase
from aiida.backends.profile import BACKEND_DJANGO, BACKEND_SQLA
Expand Down Expand Up @@ -29,3 +35,6 @@ def tearDown(self):
with self.assertRaises(Exception):
load_node(self.data_pk)


if __name__ == '__main__':
unittest.main()
10 changes: 8 additions & 2 deletions aiida/utils/fixtures.py
Expand Up @@ -3,9 +3,14 @@

Usage (unittest)::

import os

MyTestCase(aiida.utils.fixtures.PluginTestCase):

BACKEND = <load from env variable etc>
BACKEND = os.environ.get('TEST_BACKEND')
# load the backend to be tested from the environment variable
# proceed the test command with TEST_BACKEND='django' | 'sqlalchemy'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simply prepend the test command by TEST_BACKEND='django' or TEST_BACKEND='sqlalchemy'

# or set the TEST_BACKEND in your CI configuration

def setUp(self):
# load my test data
Expand Down Expand Up @@ -38,6 +43,7 @@ def test_my_stuff(test_data):
import unittest
import tempfile
import shutil
import os
from os import path
from contextlib import contextmanager

Expand Down Expand Up @@ -421,7 +427,7 @@ class PluginTestCase(unittest.TestCase):
* set to use the temporary config folder
* create and configure a profile
"""
BACKEND = BACKEND_DJANGO
BACKEND = os.environ.get('TEST_BACKEND')

@classmethod
def setUpClass(cls):
Expand Down