diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dummy_backend/__init__.py | 4 | ||||
-rw-r--r-- | tests/dummy_backend/backend.py | 4 | ||||
-rw-r--r-- | tests/test_g_sorcery.py | 16 |
3 files changed, 24 insertions, 0 deletions
diff --git a/tests/dummy_backend/__init__.py b/tests/dummy_backend/__init__.py new file mode 100644 index 0000000..2ad1e71 --- /dev/null +++ b/tests/dummy_backend/__init__.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +__all__ = ['backend'] diff --git a/tests/dummy_backend/backend.py b/tests/dummy_backend/backend.py new file mode 100644 index 0000000..b23785c --- /dev/null +++ b/tests/dummy_backend/backend.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +instance = 'test' diff --git a/tests/test_g_sorcery.py b/tests/test_g_sorcery.py index 7ff9992..ece991d 100644 --- a/tests/test_g_sorcery.py +++ b/tests/test_g_sorcery.py @@ -13,6 +13,10 @@ import os, subprocess, tempfile, unittest +from g_sorcery import g_sorcery + +from tests.dummy_backend import backend as dummyBackend + class TestBin(unittest.TestCase): def setUp(self): self.tempdir = tempfile.TemporaryDirectory() @@ -42,9 +46,21 @@ class TestBin(unittest.TestCase): self.assertRaises(subprocess.CalledProcessError, subprocess.check_output, './g-empty') os.chdir(prev) +class TestGSorcery(unittest.TestCase): + def setUp(self): + self.tempdir = tempfile.TemporaryDirectory() + + def tearDown(self): + del self.tempdir + + def test_get_backend(self): + self.assertEqual(g_sorcery.get_backend('nonexistent_backend'), None) + self.assertEqual(g_sorcery.get_backend('dummy_backend'), dummyBackend.instance) + def suite(): suite = unittest.TestSuite() suite.addTest(TestBin('test_g_sorcery')) suite.addTest(TestBin('test_nonexistent_backend')) suite.addTest(TestBin('test_empty_config')) + suite.addTest(TestGSorcery('test_get_backend')) return suite |