import unittest import pymongo from db_model import addLogEntry, getDbObject, getClientObject from config_reader import getDbName from log import LOG_LVL_INFO from log import LOG_LVL_CRITICAL client = getClientObject() # DB TEST_DB = 'testservice' TEST_DB_MASTER = getDbName() # VALUES TEST_USER_ID = 'test_user_id' TEST_MSG = 'test_msg' TEST_SERVICE = 'service' TEST_LOG_LEVEL_INFO = LOG_LVL_INFO TEST_LOG_LEVEL_CRITICAL = LOG_LVL_CRITICAL # COLLECTIONS LOG = 'log' # FIELDS TEST_USER_ID_FIELD = 'user_id' TEST_MSG_FIELD = 'message' TEST_SERVICE_FIELD = 'service' TEST_LEVEL_FIELD = 'level' db = getDbObject(TEST_DB) db_master = getDbObject(TEST_DB_MASTER)
#!/usr/bin/env python # -*- coding: utf-8 -*- from db_model import closeConnection, getClientObject from db_model import MONGO_CLIENT from unittest import TestCase getClientObject() class test_GT_1404Close_MongoClient(TestCase): def test_Close_MongoClient(self): self.assertEquals(MONGO_CLIENT.is_primary, True) closeConnection() self.assertEquals(MONGO_CLIENT.is_primary, False)
import unittest import pymongo from db_model import addLogEntry, getDbObject, getClientObject from config_reader import getDbName from log import LOG_LVL_INFO from log import LOG_LVL_CRITICAL client = getClientObject() # DB TEST_DB = "testservice" TEST_DB_MASTER = getDbName() # VALUES TEST_USER_ID = "test_user_id" TEST_MSG = "test_msg" TEST_SERVICE = "service" TEST_LOG_LEVEL_INFO = LOG_LVL_INFO TEST_LOG_LEVEL_CRITICAL = LOG_LVL_CRITICAL # COLLECTIONS LOG = "log" # FIELDS TEST_USER_ID_FIELD = "user_id" TEST_MSG_FIELD = "message" TEST_SERVICE_FIELD = "service" TEST_LEVEL_FIELD = "level" db = getDbObject(TEST_DB) db_master = getDbObject(TEST_DB_MASTER)