Commit 679480d6 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[devtools] Handle i18ncube command for "cubes as packages"

And add a test so that both layouts are tested.

Move the test cube into a package.

Related to #13001466.
parent 8987a05950dc
......@@ -16,7 +16,7 @@ syntax: regexp
.*/data.*/database/.*
.*/data/ldapdb/.*
.*/data/uicache/
.*/data/cubes/.*/i18n/.*\.po
.*/data/libpython/cubicweb_.*/i18n/.*\.po
^doc/html/
^doc/doctrees/
^doc/book/en/devweb/js_api/
......
......@@ -115,6 +115,8 @@ def generate_schema_pot(w, cubedir=None):
from cubicweb.cwvreg import CWRegistryStore
if cubedir:
cube = osp.split(cubedir)[-1]
if cube.startswith('cubicweb_'):
cube = cube[len('cubicweb_'):]
config = DevConfiguration(cube)
depcubes = list(config._cubes)
depcubes.remove(cube)
......
../libpython/cubicweb_i18ntestcube/
\ No newline at end of file
......@@ -56,6 +56,16 @@ class cubePotGeneratorTC(TestCase):
"""test case for i18n pot file generator"""
def test_i18ncube(self):
env = os.environ.copy()
if 'PYTHONPATH' in env:
env['PYTHONPATH'] += os.pathsep
else:
env['PYTHONPATH'] = ''
env['PYTHONPATH'] += osp.join(DATADIR, 'libpython')
cubedir = osp.join(DATADIR, 'libpython', 'cubicweb_i18ntestcube')
self._check(cubedir, env)
def test_i18ncube_legacy_layout(self):
env = os.environ.copy()
env['CW_CUBES_PATH'] = osp.join(DATADIR, 'cubes')
if 'PYTHONPATH' in env:
......@@ -63,13 +73,17 @@ class cubePotGeneratorTC(TestCase):
else:
env['PYTHONPATH'] = ''
env['PYTHONPATH'] += DATADIR
cubedir = osp.join(DATADIR, 'cubes', 'i18ntestcube')
self._check(cubedir, env)
def _check(self, cubedir, env):
cmd = [sys.executable, '-m', 'cubicweb', 'i18ncube', 'i18ntestcube']
proc = Popen(cmd, env=env, stdout=PIPE, stderr=STDOUT)
stdout, _ = proc.communicate()
self.assertEqual(proc.returncode, 0, msg=stdout)
cube = osp.join(DATADIR, 'cubes', 'i18ntestcube')
msgs = load_po(osp.join(cube, 'i18n', 'en.po.ref'))
newmsgs = load_po(osp.join(cube, 'i18n', 'en.po'))
msg = stdout.decode(sys.getdefaultencoding(), errors='replace')
self.assertEqual(proc.returncode, 0, msg=msg)
msgs = load_po(osp.join(cubedir, 'i18n', 'en.po.ref'))
newmsgs = load_po(osp.join(cubedir, 'i18n', 'en.po'))
self.assertEqual(msgs, newmsgs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment