aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-01 23:42:06 +0200
committerJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-01 23:42:06 +0200
commitc9ad38ff53c9dc8baa38a9b888c3e83a7b47dc1b (patch)
treeb55baa210c35b27b0e88327c2b64e81b4bc7da2d /tests
parentg_sorcery/g_sorcery: backend config, initial commit (diff)
downloadg-sorcery-c9ad38ff53c9dc8baa38a9b888c3e83a7b47dc1b.tar.gz
g-sorcery-c9ad38ff53c9dc8baa38a9b888c3e83a7b47dc1b.tar.bz2
g-sorcery-c9ad38ff53c9dc8baa38a9b888c3e83a7b47dc1b.zip
g_sorcery/g_sorcery: get_backend
Diffstat (limited to 'tests')
-rw-r--r--tests/dummy_backend/__init__.py4
-rw-r--r--tests/dummy_backend/backend.py4
-rw-r--r--tests/test_g_sorcery.py16
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