28 |
28 |
29 MTIME = datetime.now() - timedelta(0, 10) |
29 MTIME = datetime.now() - timedelta(0, 10) |
30 repo2, cnx2 = init_test_database(config=ExternalSource1Configuration('data')) |
30 repo2, cnx2 = init_test_database(config=ExternalSource1Configuration('data')) |
31 repo3, cnx3 = init_test_database(config=ExternalSource2Configuration('data')) |
31 repo3, cnx3 = init_test_database(config=ExternalSource2Configuration('data')) |
32 |
32 |
33 # XXX, access existing connection, no pyro connection |
33 # hi-jacking |
34 from cubicweb.server.sources.pyrorql import PyroRQLSource |
34 from cubicweb.server.sources.pyrorql import PyroRQLSource |
35 PyroRQLSource.get_connection = lambda x: x.uri == 'extern-multi' and cnx3 or cnx2 |
|
36 # necessary since the repository is closing its initial connections pool though |
|
37 # we want to keep cnx2 valid |
|
38 from cubicweb.dbapi import Connection |
35 from cubicweb.dbapi import Connection |
39 Connection.close = lambda x: None |
36 |
|
37 PyroRQLSource_get_connection = PyroRQLSource.get_connection |
|
38 Connection_close = Connection.close |
|
39 |
|
40 def setup_module(*args): |
|
41 # hi-jack PyroRQLSource.get_connection to access existing connection (no |
|
42 # pyro connection) |
|
43 PyroRQLSource.get_connection = lambda x: x.uri == 'extern-multi' and cnx3 or cnx2 |
|
44 # also necessary since the repository is closing its initial connections |
|
45 # pool though we want to keep cnx2 valid |
|
46 Connection.close = lambda x: None |
|
47 |
|
48 def teardown_module(*args): |
|
49 PyroRQLSource.get_connection = PyroRQLSource_get_connection |
|
50 Connection.close = Connection_close |
|
51 |
40 |
52 |
41 class TwoSourcesTC(CubicWebTC): |
53 class TwoSourcesTC(CubicWebTC): |
42 config = TwoSourcesConfiguration('data') |
54 config = TwoSourcesConfiguration('data') |
43 |
55 |
44 @classmethod |
56 @classmethod |