tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_localization.py (1748B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 import os
      6 import sys
      7 
      8 from marionette_driver import By
      9 from marionette_driver.errors import (
     10    InvalidArgumentException,
     11    NoSuchElementException,
     12    UnknownException,
     13 )
     14 from marionette_driver.localization import L10n
     15 from marionette_harness import MarionetteTestCase
     16 
     17 # add this directory to the path
     18 sys.path.append(os.path.dirname(__file__))
     19 
     20 from chrome_handler_mixin import ChromeHandlerMixin
     21 
     22 
     23 class TestL10n(ChromeHandlerMixin, MarionetteTestCase):
     24    def setUp(self):
     25        super(TestL10n, self).setUp()
     26 
     27        self.l10n = L10n(self.marionette)
     28 
     29    def test_localize_property(self):
     30        properties = [self.chrome_base_url + "test_dialog.properties"]
     31 
     32        value = self.l10n.localize_property(properties, "testDialog.title")
     33        self.assertEqual(value, "Test Dialog")
     34 
     35        self.assertRaises(
     36            NoSuchElementException,
     37            self.l10n.localize_property,
     38            properties,
     39            "notExistent",
     40        )
     41 
     42    def test_localize_property_invalid_arguments(self):
     43        properties = ["chrome://global/locale/filepicker.properties"]
     44 
     45        self.assertRaises(
     46            NoSuchElementException,
     47            self.l10n.localize_property,
     48            properties,
     49            "notExistent",
     50        )
     51        self.assertRaises(
     52            InvalidArgumentException,
     53            self.l10n.localize_property,
     54            properties[0],
     55            "notExistent",
     56        )
     57        self.assertRaises(
     58            InvalidArgumentException, self.l10n.localize_property, properties, True
     59        )