Show More
@@ -1,52 +1,56 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 | 19 | import os |
|
20 | 20 | |
|
21 | 21 | from unittest import TestCase |
|
22 | 22 | |
|
23 | 23 | from nose import SkipTest |
|
24 | 24 | |
|
25 | 25 | from pymongo import Connection |
|
26 | 26 | from IPython.parallel.controller.mongodb import MongoDB |
|
27 | 27 | |
|
28 | 28 | from . import test_db |
|
29 | 29 | |
|
30 | 30 | conn_kwargs = {} |
|
31 | 31 | if 'DB_IP' in os.environ: |
|
32 | 32 | conn_kwargs['host'] = os.environ['DB_IP'] |
|
33 | if 'DBA_MONGODB_ADMIN_URI' in os.environ: | |
|
34 | # On ShiningPanda, we need a username and password to connect. They are | |
|
35 | # passed in a mongodb:// URI. | |
|
36 | conn_kwargs['host'] = os.environ['DBA_MONGODB_ADMIN_URI'] | |
|
33 | 37 | if 'DB_PORT' in os.environ: |
|
34 | 38 | conn_kwargs['port'] = int(os.environ['DB_PORT']) |
|
35 | 39 | |
|
36 | 40 | try: |
|
37 | 41 | c = Connection(**conn_kwargs) |
|
38 | 42 | except Exception: |
|
39 | 43 | c=None |
|
40 | 44 | |
|
41 | 45 | class TestMongoBackend(test_db.TaskDBTest, TestCase): |
|
42 | 46 | """MongoDB backend tests""" |
|
43 | 47 | |
|
44 | 48 | def create_db(self): |
|
45 | 49 | try: |
|
46 | 50 | return MongoDB(database='iptestdb', _connection=c) |
|
47 | 51 | except Exception: |
|
48 | 52 | raise SkipTest("Couldn't connect to mongodb") |
|
49 | 53 | |
|
50 | 54 | def teardown(self): |
|
51 | 55 | if c is not None: |
|
52 | 56 | c.drop_database('iptestdb') |
General Comments 0
You need to be logged in to leave comments.
Login now