|
8 | 8 | :copyright: Copyright 2019 by Takayuki SHIMIZUKAWA.
|
9 | 9 | :license: BSD, see LICENSE for details.
|
10 | 10 | """
|
| 11 | + |
| 12 | +import os |
| 13 | + |
11 | 14 | from click.testing import CliRunner
|
12 | 15 |
|
13 | 16 | from sphinx_intl import commands
|
@@ -67,6 +70,38 @@ def test_update_difference_detect(temp):
|
67 | 70 | assert r4.output.count('Not Changed:') == 1
|
68 | 71 |
|
69 | 72 |
|
| 73 | +def test_update_line_width(temp): |
| 74 | + with open('_build/locale/README.pot', 'r') as f: |
| 75 | + template = f.read() |
| 76 | + |
| 77 | + with open('_build/locale/README.pot', 'w') as f: |
| 78 | + f.write(template) |
| 79 | + f.write('\nmsgid "foorbar identifier1"\nmsgstr ""\n') |
| 80 | + |
| 81 | + po_dir = os.path.join('locale', 'ja', 'LC_MESSAGES') |
| 82 | + po_file = os.path.join(po_dir, 'README.po') |
| 83 | + |
| 84 | + r1 = runner.invoke(commands.update, ['-d', 'locale', '-p', '_build/locale', '-l', 'ja']) |
| 85 | + assert r1.exit_code == 0 |
| 86 | + |
| 87 | + with open(po_file, 'r') as f: |
| 88 | + contents = f.read() |
| 89 | + assert '"foorbar identifier1"\n' in contents |
| 90 | + |
| 91 | + # change the identifier to trigger an update and impose a lower line-width count |
| 92 | + with open('_build/locale/README.pot', 'w') as f: |
| 93 | + f.write(template) |
| 94 | + f.write('\nmsgid "foorbar identifier2"\nmsgstr ""\n') |
| 95 | + |
| 96 | + r2 = runner.invoke(commands.update, ['-d', 'locale', '-p', '_build/locale', '-w', '1']) |
| 97 | + assert r2.exit_code == 0 |
| 98 | + |
| 99 | + with open(po_file, 'r') as f: |
| 100 | + contents = f.read() |
| 101 | + assert '"foorbar"\n' in contents |
| 102 | + assert '"identifier2"\n' in contents |
| 103 | + |
| 104 | + |
70 | 105 | def test_stat(temp):
|
71 | 106 | r1 = runner.invoke(commands.update, ['-d', 'locale', '-p', '_build/locale', '-l', 'ja'])
|
72 | 107 | assert r1.exit_code == 0
|
|
0 commit comments