2014-09-02 20:26:59 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-09-02 15:10:42 -04:00
|
|
|
"""
|
|
|
|
OnionShare | https://onionshare.org/
|
|
|
|
|
2017-01-06 21:58:15 -05:00
|
|
|
Copyright (C) 2017 Micah Lee <micah@micahflee.com>
|
2014-09-02 15:10:42 -04:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
"""
|
2016-09-05 13:41:20 -04:00
|
|
|
import locale, os
|
2016-09-04 23:02:20 -04:00
|
|
|
from onionshare import helpers, strings
|
2014-08-26 21:38:46 -04:00
|
|
|
|
2016-09-05 13:41:20 -04:00
|
|
|
# Stub get_resource_path so it finds the correct path while running tests
|
|
|
|
def get_resource_path(filename):
|
2017-02-21 20:14:53 -05:00
|
|
|
resources_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'share')
|
2016-09-05 13:41:20 -04:00
|
|
|
path = os.path.join(resources_dir, filename)
|
|
|
|
return path
|
|
|
|
helpers.get_resource_path = get_resource_path
|
2014-11-18 12:29:32 -05:00
|
|
|
|
2014-08-26 21:38:46 -04:00
|
|
|
def test_starts_with_empty_strings():
|
2014-11-18 11:39:04 -05:00
|
|
|
"""creates an empty strings dict by default"""
|
2014-08-26 21:38:46 -04:00
|
|
|
assert strings.strings == {}
|
|
|
|
|
2014-11-18 12:29:32 -05:00
|
|
|
|
2014-08-26 21:38:46 -04:00
|
|
|
def test_load_strings_defaults_to_english():
|
2014-11-18 11:39:04 -05:00
|
|
|
"""load_strings() loads English by default"""
|
2014-08-26 21:38:46 -04:00
|
|
|
locale.getdefaultlocale = lambda: ('en_US', 'UTF-8')
|
2016-09-04 23:02:20 -04:00
|
|
|
strings.load_strings(helpers)
|
2014-09-17 20:26:22 -04:00
|
|
|
assert strings._('wait_for_hs') == "Waiting for HS to be ready:"
|
2014-08-26 21:38:46 -04:00
|
|
|
|
2014-11-18 12:29:32 -05:00
|
|
|
|
2014-08-26 21:38:46 -04:00
|
|
|
def test_load_strings_loads_other_languages():
|
2014-11-18 11:39:04 -05:00
|
|
|
"""load_strings() loads other languages in different locales"""
|
2014-08-26 21:38:46 -04:00
|
|
|
locale.getdefaultlocale = lambda: ('fr_FR', 'UTF-8')
|
2016-09-04 23:02:20 -04:00
|
|
|
strings.load_strings(helpers, "fr")
|
2014-09-17 20:26:22 -04:00
|
|
|
assert strings._('wait_for_hs') == "En attente du HS:"
|