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:
parent
d4a5ee3433
commit
3091533fd0
2 changed files with 25 additions and 0 deletions
0
tests/migration_handler/__init__.py
Normal file
0
tests/migration_handler/__init__.py
Normal file
25
tests/migration_handler/test_db_init.py
Normal file
25
tests/migration_handler/test_db_init.py
Normal 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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue