Example #1
0
def test_confpy_in_subdir(temp):
    os.mkdir('source')
    f = open('source/conf.py', 'w')
    f.write('locale_dirs=["somedir"]\n')
    f.close()
    opts, args = commands.parse_option(['update', '-c', 'source/conf.py'])
    assert opts.locale_dir == os.path.normpath('source/somedir')
def test_update_txconfig_resources_with_config(temp):
    tx_dir = temp / '.tx'
    tx_dir.makedirs()
    (tx_dir / 'config').write_text(dedent("""\
    [main]
    host = https://www.transifex.com

    [ham-project.domain1]
    """))

    (temp / '_build' / 'locale').copytree(temp / 'locale' / 'pot')

    cmd = 'update-txconfig-resources'
    options, args = commands.parse_option([cmd, '-d', 'locale'])
    commands.commands[cmd](options)

    data = (tx_dir / 'config').text()
    assert re.search(r'\[ham-project\.README\]', data)
def test_update_txconfig_resources_with_config(temp):
    tx_dir = temp / '.tx'
    tx_dir.makedirs()
    (tx_dir / 'config').write_text(
        dedent("""\
    [main]
    host = https://www.transifex.com

    [ham-project.domain1]
    """))

    (temp / '_build' / 'locale').copytree(temp / 'locale' / 'pot')

    cmd = 'update-txconfig-resources'
    options, args = commands.parse_option([cmd, '-d', 'locale'])
    commands.commands[cmd](options)

    data = (tx_dir / 'config').text()
    assert re.search(r'\[ham-project\.README\]', data)
Example #4
0
def test_no_confpy_and_locale_dir_specified(temp):
    opts, args = commands.parse_option(['update', '-d', 'somedir'])
    assert opts.locale_dir == 'somedir'
Example #5
0
def test_confpy_have_locale_dirs(temp):
    f = open('conf.py', 'w')
    f.write('locale_dirs=["somedir"]\n')
    f.close()
    opts, args = commands.parse_option(['update'])
    assert opts.locale_dir == 'somedir'
Example #6
0
def test_confpy_not_have_locale_dirs(temp):
    f = open('conf.py', 'w')
    f.close()
    commands.parse_option(['update'])
Example #7
0
def test_command_not_found(temp):
    commands.parse_option(['some-command'])