예제 #1
0
파일: forms.py 프로젝트: BMeu/Aerarium
    def __init__(self, *args: Any, **kwargs: Any) -> None:
        """
            :param args: The arguments for initializing the form.
            :param kwargs: The keyword argument for initializing the form.
        """

        super().__init__(*args, **kwargs)

        self.language.choices = get_language_names(
            BaseConfiguration.TRANSLATION_DIR)
예제 #2
0
파일: forms.py 프로젝트: BMeu/Aerarium
    def __init__(self, *args, **kwargs) -> None:
        """
            Initialize the form.

            :param args: The arguments for initializing the form.
            :param kwargs: The keyworded argument for initializing the form.
        """
        super().__init__(*args, **kwargs)

        self.language.choices = get_language_names(BaseConfiguration.TRANSLATION_DIR)
예제 #3
0
파일: forms_test.py 프로젝트: BMeu/Aerarium
    def test_init(self):
        """
            Test that the form is correctly initialized.

            Expected result: The language field is initialized with the available languages.
        """

        languages = get_language_names(TestConfiguration.TRANSLATION_DIR)
        form = UserSettingsForm()
        self.assertListEqual(list(languages), form.language.choices)
예제 #4
0
    def test_init(self):
        """
            Test that the form is correctly initialized.

            Expected result: The language field is initialized with the available languages.
        """

        languages = get_language_names(TestConfiguration.TRANSLATION_DIR)
        form = UserSettingsForm()
        self.assertListEqual(list(languages), form.language.choices)
예제 #5
0
    def test_get_language_names_with_native_names_english(
            self, mock_listdir: MagicMock):
        """
            Test getting the list of language names with their native names (with 'en' as locale).

            Expected result: The list is returned and sorted by their name.
        """

        mock_listdir.return_value = [
            'es',
            'fr',
            'de',
        ]
        expected_names = [
            ('en', 'English'),
            ('fr', 'French (français)'),
            ('de', 'German (Deutsch)'),
            ('es', 'Spanish (español)'),
        ]

        names = get_language_names(TestConfiguration.TRANSLATION_DIR)
        mock_listdir.assert_called()
        self.assertListEqual(expected_names, list(names))
예제 #6
0
    def test_get_language_names_without_native_names(self,
                                                     mock_listdir: MagicMock):
        """
            Test getting the list of language names without their native names.

            Expected result: The list is returned and sorted by their name.
        """

        mock_listdir.return_value = [
            'es',
            'fr',
            'de',
        ]
        expected_names = [
            ('en', 'English'),
            ('fr', 'French'),
            ('de', 'German'),
            ('es', 'Spanish'),
        ]

        names = get_language_names(TestConfiguration.TRANSLATION_DIR,
                                   with_native_names=False)
        mock_listdir.assert_called()
        self.assertListEqual(expected_names, list(names))