No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_db_init.py 1.3KB

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8 -*-
  2. from lodel import buildconf
  3. if not buildconf.PYMONGO:
  4. import warnings
  5. warnings.warn("Skipping tests about mongodb datasource. Pymongo not installed")
  6. else:
  7. import unittest
  8. from plugins.mongodb_datasource.migration_handler import *
  9. class MongoDbMigrationHandlerTestCase(unittest.TestCase):
  10. def test_check_connection_args(self):
  11. empty_connection_args = {}
  12. with self.assertRaises(TypeError):
  13. MigrationHandler(empty_connection_args)
  14. bad_connection_args_dicts = [
  15. {'host': 'localhost', 'port': 20030},
  16. {'host': 'localhost', 'port': 28015},
  17. {'host': 'localhost', 'port': 28015, 'login':'lodel', 'password': 'lap'}
  18. ]
  19. for bad_connection_args_dict in bad_connection_args_dicts:
  20. with self.assertRaises(TypeError):
  21. MigrationHandler(bad_connection_args_dict)
  22. ## @todo pass the connection arguments in the settings
  23. @unittest.skip
  24. def test_init_db(self):
  25. correct_connection_args = {'host': 'localhost', 'port': 28015, 'username': 'lodel_admin', 'password': 'lapwd', 'db_name': 'lodel'}
  26. migration_handler = MigrationHandler(correct_connection_args)
  27. migration_handler.init_db()