コード例 #1
0
def test_resolve_locales(intercept_populated, temp_site):
    """Test if locales are resolved correctly.

    In this environment, no languages have to be added.
    """
    api = XTMCloudAPI(_API_TOKEN_VALID)
    source = FileSource(str(temp_site))
    source.write_to_config('XTM', 'project_id', str(_PROJECT_ID))

    utils.resolve_locales(api, source)
コード例 #2
0
def test_resolve_locales_adds_langs(intercept, temp_site):
    """Test if locales are resolved correctly.

    In this environment, new target languages are added.
    """
    api = XTMCloudAPI(_API_TOKEN_VALID)
    source = FileSource(str(temp_site))
    source.write_to_config('XTM', 'project_id', str(_PROJECT_ID))
    exp_targets = {'de_DE'}

    utils.resolve_locales(api, source)

    assert exp_targets == api.get_target_languages(_PROJECT_ID)
コード例 #3
0
def test_resolve_locales_raise_exception(intercept_populated, temp_site):
    """Test if locales are resolved correctly.

    In this environment, the API has more target languages configured than are
    available online. We except an exception to be raised.
    """
    api = XTMCloudAPI(_API_TOKEN_VALID)
    api.add_target_languages(_PROJECT_ID, ['ro_RO'])
    source = FileSource(str(temp_site))
    source.write_to_config('XTM', 'project_id', str(_PROJECT_ID))
    exp_msg = ('The following languages are enabled in the API, but not '
               "listed in locales: set(['ro_RO'])! Please remove them manually"
               ' from project number 1234 and then re-run the script!')

    exception_test(utils.resolve_locales, Exception, exp_msg, api, source)