##// END OF EJS Templates
Respect DB_IP and DB_PORT in mongodb tests....
Michał Górny -
Show More
@@ -1,44 +1,52 b''
1 1 """Tests for mongodb backend
2 2
3 3 Authors:
4 4
5 5 * Min RK
6 6 """
7 7
8 8 #-------------------------------------------------------------------------------
9 9 # Copyright (C) 2011 The IPython Development Team
10 10 #
11 11 # Distributed under the terms of the BSD License. The full license is in
12 12 # the file COPYING, distributed as part of this software.
13 13 #-------------------------------------------------------------------------------
14 14
15 15 #-------------------------------------------------------------------------------
16 16 # Imports
17 17 #-------------------------------------------------------------------------------
18 18
19 import os
20
19 21 from unittest import TestCase
20 22
21 23 from nose import SkipTest
22 24
23 25 from pymongo import Connection
24 26 from IPython.parallel.controller.mongodb import MongoDB
25 27
26 28 from . import test_db
27 29
30 conn_kwargs = {}
31 if 'DB_IP' in os.environ:
32 conn_kwargs['host'] = os.environ['DB_IP']
33 if 'DB_PORT' in os.environ:
34 conn_kwargs['port'] = int(os.environ['DB_PORT'])
35
28 36 try:
29 c = Connection()
37 c = Connection(**conn_kwargs)
30 38 except Exception:
31 39 c=None
32 40
33 41 class TestMongoBackend(test_db.TaskDBTest, TestCase):
34 42 """MongoDB backend tests"""
35 43
36 44 def create_db(self):
37 45 try:
38 46 return MongoDB(database='iptestdb', _connection=c)
39 47 except Exception:
40 48 raise SkipTest("Couldn't connect to mongodb")
41 49
42 50 def teardown(self):
43 51 if c is not None:
44 52 c.drop_database('iptestdb')
General Comments 0
You need to be logged in to leave comments. Login now