def get_version_name(self): if self.config.latest_nightly or self.config.latest_aurora: json = load_json_url(self.json_version_url) version_code = json[ 'FIREFOX_NIGHTLY'] if self.config.latest_nightly else json[ 'FIREFOX_AURORA'] return version_code return self.config.version
def locale_mapping(locale): """ Google play and Mozilla don't have the exact locale code Translate them """ global _mappings if _mappings is None: _mappings = utils.load_json_url(MAPPING_URL) return _mappings[locale] if locale in _mappings else locale
def load_mapping(self): """ Download and load the locale mapping """ self.mappings = load_json_url(self.mapping_url)
def get_translation(self, package_name, locale): """ Get the translation for a locale """ return load_json_url( self.locale_url.format(channel=package_name, locale=locale))
def get_list_locales(self, package_name): """ Get all the translated locales supported by Google play So, locale unsupported by Google play won't be downloaded Idem for not translated locale """ return load_json_url(self.all_locales_url.format(channel=package_name))
def test_load_json_url(monkeypatch): response_mock = MagicMock() response_mock.json = MagicMock() monkeypatch.setattr(requests, 'get', lambda url: response_mock) load_json_url('https://dummy-url.tld') response_mock.json.assert_called_once_with()
def get_translation(release_channel, locale): """ Get the translation for a locale """ return utils.load_json_url(LOCALE_URL.format(channel=release_channel, locale=locale))
def get_list_locales(release_channel): """ Get all the translated locales supported by Google play So, locale unsupported by Google play won't be downloaded Idem for not translated locale """ return utils.load_json_url(ALL_LOCALES_URL.format(channel=release_channel))