cubicweb/server/test/unittest_serverctl.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Tue, 21 Jun 2016 16:35:21 +0200
changeset 11301 a76feec0a861
parent 11269 73ac69970047
child 11355 47b0b08fbb4b
permissions -rw-r--r--
Merge with 3.22.3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
9e64fddebc89 merge with 3.21.3
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10825
diff changeset
     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
11269
73ac69970047 [devtools] Simplify test configuration's init
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
    12
        config_for = lambda appid: ApptestConfiguration(appid, __file__)
10960
9e64fddebc89 merge with 3.21.3
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10825
diff changeset
    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()