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