def test_environ_fallback(self): DUMMY_CONFIG['mongo'].pop('user') uri, port = _get_mongo_uri(DUMMY_CONFIG) self.assertEqual( 'mongodb://*****:*****@hst1/subsidieservice?authMechanism=SCRAM-SHA-1', uri) self.assertEqual(1231, port)
def test_no_port(self): os.environ.pop('MONGO_PORT') uri, port = _get_mongo_uri({}) self.assertEqual( 'mongodb://*****:*****@hst2/subsidieservice?authMechanism=SCRAM-SHA-1', uri) self.assertIsNone(port)
def test_no_password(self): os.environ.pop('MONGO_PASSWORD') uri, port = _get_mongo_uri({}) self.assertEqual( 'mongodb://usr2@hst2/subsidieservice?authMechanism=SCRAM-SHA-1', uri) self.assertEqual(1232, port)
def test_config_fallback(self): os.environ.pop('MONGO_HOST') os.environ.pop('MONGO_USER') os.environ.pop('MONGO_PORT') os.environ.pop('MONGO_PASSWORD') uri, port = _get_mongo_uri(DUMMY_CONFIG) self.assertEqual( 'mongodb://*****:*****@hst1/admin?authMechanism=SCRAM-SHA-1', uri) self.assertEqual(1231, port)
def test_no_user(self): os.environ.pop('MONGO_USER') uri, port = _get_mongo_uri({}) self.assertEqual('mongodb://hst2/admin?authMechanism=SCRAM-SHA-1', uri) self.assertEqual(1232, port)
def test_environ(self): uri, port = _get_mongo_uri({}) self.assertEqual( 'mongodb://*****:*****@hst2/admin?authMechanism=SCRAM-SHA-1', uri) self.assertEqual(1232, port)
def test_environ_priority(self): uri, port = _get_mongo_uri(DUMMY_CONFIG) self.assertEqual( 'mongodb://*****:*****@hst2/admin?authMechanism=SCRAM-SHA-1', uri) self.assertEqual(1232, port)
def test_no_host(self): os.environ.pop('MONGO_HOST') uri, port = _get_mongo_uri({}) self.assertIsNone(uri) self.assertIsNone(port)
def test_config_priority(self): uri, port = _get_mongo_uri(DUMMY_CONFIG) self.assertEqual( 'mongodb://*****:*****@hst1/subsidieservice?authMechanism=SCRAM-SHA-1', uri) self.assertEqual(1231, port)