equal
deleted
inserted
replaced
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """cubicweb.migration unit tests |
18 """cubicweb.migration unit tests""" |
19 |
19 |
20 """ |
20 from os.path import abspath, dirname, join |
21 |
|
22 from os.path import abspath |
|
23 from logilab.common.testlib import TestCase, unittest_main |
21 from logilab.common.testlib import TestCase, unittest_main |
24 |
22 |
25 from cubicweb.devtools import TestServerConfiguration |
23 from cubicweb.devtools import TestServerConfiguration |
26 from cubicweb.cwconfig import CubicWebConfiguration |
24 from cubicweb.cwconfig import CubicWebConfiguration |
27 from cubicweb.migration import MigrationHelper, filter_scripts |
25 from cubicweb.migration import MigrationHelper, filter_scripts |
30 |
28 |
31 class Schema(dict): |
29 class Schema(dict): |
32 def has_entity(self, e_type): |
30 def has_entity(self, e_type): |
33 return self.has_key(e_type) |
31 return self.has_key(e_type) |
34 |
32 |
35 SMIGRDIR = abspath('data/server_migration') + '/' |
33 SMIGRDIR = join(dirname(__file__), 'data', 'server_migration') + '/' |
36 TMIGRDIR = abspath('data/migration') + '/' |
34 TMIGRDIR = join(dirname(__file__), 'data', 'migration') + '/' |
37 |
35 |
38 class MigrTestConfig(TestServerConfiguration): |
36 class MigrTestConfig(TestServerConfiguration): |
39 verbosity = 0 |
37 verbosity = 0 |
40 def migration_scripts_dir(cls): |
38 def migration_scripts_dir(cls): |
41 return SMIGRDIR |
39 return SMIGRDIR |
103 |
101 |
104 class BaseCreationTC(TestCase): |
102 class BaseCreationTC(TestCase): |
105 |
103 |
106 def test_db_creation(self): |
104 def test_db_creation(self): |
107 """make sure database can be created""" |
105 """make sure database can be created""" |
108 config = ApptestConfiguration('data') |
106 config = ApptestConfiguration('data', apphome=self.datadir) |
109 source = config.sources()['system'] |
107 source = config.sources()['system'] |
110 self.assertEqual(source['db-driver'], 'sqlite') |
108 self.assertEqual(source['db-driver'], 'sqlite') |
111 cleanup_sqlite(source['db-name'], removetemplate=True) |
109 cleanup_sqlite(source['db-name'], removetemplate=True) |
112 init_test_database(config=config) |
110 init_test_database(config=config) |
113 |
111 |