1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-06-07 11:30:48 +02:00
lodel2_mirror/tests/migration_handler/test_db_init.py
Yann 8316ab82ff Configure autotools for distributing lodel2
IMPORTANT : tests are broken. See details below

A new lodel/buildconf.py.ini file created. It will be transformed to a lodel/buildconf.py file by ./configure .
This file goal is to store build time constant (for the moment the presence of pymongo).
You have to build lodel2 before being able to run the tests.
2016-08-30 14:01:25 +02:00

32 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
from lodel import buildconf
if not buildconf.PYMONGO:
import warnings
warnings.warn("Skipping tests about mongodb datasource. Pymongo not installed")
else:
import unittest
from plugins.mongodb_datasource.migration_handler import *
class MongoDbMigrationHandlerTestCase(unittest.TestCase):
def test_check_connection_args(self):
empty_connection_args = {}
with self.assertRaises(TypeError):
MigrationHandler(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(TypeError):
MigrationHandler(bad_connection_args_dict)
## @todo pass the connection arguments in the settings
@unittest.skip
def test_init_db(self):
correct_connection_args = {'host': 'localhost', 'port': 28015, 'username': 'lodel_admin', 'password': 'lapwd', 'db_name': 'lodel'}
migration_handler = MigrationHandler(correct_connection_args)
migration_handler.init_db()