author | Rémi Cardona <remi.cardona@logilab.fr> |
Thu, 10 Dec 2015 12:34:15 +0100 | |
changeset 10960 | 9e64fddebc89 |
parent 10825 | 56ca5f6e0533 |
permissions | -rw-r--r-- |
10825
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
1 |
import os.path as osp |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
2 |
import shutil |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
3 |
|
10960 | 4 |
from cubicweb.devtools import testlib, ApptestConfiguration |
10825
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
5 |
from cubicweb.server.serverctl import _local_dump, DBDumpCommand |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
6 |
from cubicweb.server.serverconfig import ServerConfiguration |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
7 |
|
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
8 |
class ServerCTLTC(testlib.CubicWebTC): |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
9 |
def setUp(self): |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
10 |
super(ServerCTLTC, self).setUp() |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
11 |
self.orig_config_for = ServerConfiguration.config_for |
10960 | 12 |
config_for = lambda appid: ApptestConfiguration(appid, apphome=self.datadir) |
13 |
ServerConfiguration.config_for = staticmethod(config_for) |
|
10825
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
14 |
|
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
15 |
def tearDown(self): |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
16 |
ServerConfiguration.config_for = self.orig_config_for |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
17 |
super(ServerCTLTC, self).tearDown() |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
18 |
|
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
19 |
def test_dump(self): |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
20 |
DBDumpCommand(None).run([self.appid]) |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
21 |
shutil.rmtree(osp.join(self.config.apphome, 'backup')) |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
22 |
|
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
23 |
|
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
24 |
if __name__ == '__main__': |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
25 |
from unittest import main |
56ca5f6e0533
[server/test] add test for db-dump command
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
26 |
main() |