aboutsummaryrefslogtreecommitdiffstats
path: root/brevisurl/tests/test_brevisurl.py
diff options
context:
space:
mode:
Diffstat (limited to 'brevisurl/tests/test_brevisurl.py')
-rw-r--r--brevisurl/tests/test_brevisurl.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/brevisurl/tests/test_brevisurl.py b/brevisurl/tests/test_brevisurl.py
new file mode 100644
index 0000000..8780b05
--- /dev/null
+++ b/brevisurl/tests/test_brevisurl.py
@@ -0,0 +1,22 @@
+from django.utils import unittest
+
+from brevisurl import get_connection, shorten_url
+from brevisurl.backends.local import BrevisUrlBackend
+from brevisurl.backends.base import BaseBrevisUrlBackend
+
+
+class TestGetConnection(unittest.TestCase):
+
+ def test_get_default_connection(self):
+ connection = get_connection()
+ self.assertIsInstance(connection, BrevisUrlBackend)
+
+ def test_get_custom_connection(self):
+ base_connection = get_connection(backend='brevisurl.backends.base.BaseBrevisUrlBackend')
+ local_connection = get_connection(backend='brevisurl.backends.local.BrevisUrlBackend')
+ self.assertIsInstance(base_connection, BaseBrevisUrlBackend)
+ self.assertIsInstance(local_connection, BrevisUrlBackend)
+
+ def test_get_connection_non_existing_backend(self):
+ with self.assertRaises(AttributeError):
+ get_connection(backend='brevisurl.backends.local.NonExistingBackend') \ No newline at end of file