1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-06-07 11:30:48 +02:00

added tests for the migration_handler

This commit is contained in:
Roland Haroutiounian 2016-06-10 16:20:36 +02:00
commit 3091533fd0
2 changed files with 25 additions and 0 deletions

View file

View file

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
import unittest
from pymongo import MongoClient
from plugins.mongodb_datasource.migration_handler import *
class MongoDbMigrationHandlerTestCase(unittest.TestCase):
def test_check_connection_args(self):
empty_connection_args = {}
with self.assertRaises(MigrationHandlerError):
MongoDbMigrationHandler(empty_connection_args)
bad_connection_args_dicts = [
{'host': 'localhost', 'port': 20030},
{'host': 'localhost', 'port': 28015},
{'host': 'localhost', 'port': 28015, 'login':'lodel', 'password': 'lap'}
]
for bad_connection_args_dict in bad_connection_args_dicts:
with self.assertRaises(MigrationHandlerError):
MongoDbMigrationHandler(bad_connection_args_dict)
def test_init_db(self):
correct_connection_args = {'host': 'localhost', 'port': 28015, 'username': 'lodel_admin', 'password': 'lapwd', 'db_name': 'lodel'}
migration_handler = MongoDbMigrationHandler(correct_connection_args)
migration_handler._install_collections()