Browse Source

added tests for the migration_handler

Roland Haroutiounian 8 years ago
parent
commit
3091533fd0
2 changed files with 25 additions and 0 deletions
  1. 0
    0
      tests/migration_handler/__init__.py
  2. 25
    0
      tests/migration_handler/test_db_init.py

+ 0
- 0
tests/migration_handler/__init__.py View File


+ 25
- 0
tests/migration_handler/test_db_init.py View File

@@ -0,0 +1,25 @@
1
+# -*- coding: utf-8 -*-
2
+import unittest
3
+from pymongo import MongoClient
4
+from plugins.mongodb_datasource.migration_handler import *
5
+
6
+class MongoDbMigrationHandlerTestCase(unittest.TestCase):
7
+
8
+    def test_check_connection_args(self):
9
+        empty_connection_args = {}
10
+        with self.assertRaises(MigrationHandlerError):
11
+            MongoDbMigrationHandler(empty_connection_args)
12
+
13
+        bad_connection_args_dicts = [
14
+            {'host': 'localhost', 'port': 20030},
15
+            {'host': 'localhost', 'port': 28015},
16
+            {'host': 'localhost', 'port': 28015, 'login':'lodel', 'password': 'lap'}
17
+        ]
18
+        for bad_connection_args_dict in bad_connection_args_dicts:
19
+            with self.assertRaises(MigrationHandlerError):
20
+                MongoDbMigrationHandler(bad_connection_args_dict)
21
+
22
+    def test_init_db(self):
23
+        correct_connection_args = {'host': 'localhost', 'port': 28015, 'username': 'lodel_admin', 'password': 'lapwd', 'db_name': 'lodel'}
24
+        migration_handler = MongoDbMigrationHandler(correct_connection_args)
25
+        migration_handler._install_collections()

Loading…
Cancel
Save