def test_no_emails(self, mock_fs):
        mock_fs.emails.return_value = []
        mock_fs.read_file.return_value = '{{placeholder}}'

        placeholder.generate_config(self.settings)

        self.assertFalse(mock_fs.save_file.called)
Exemplo n.º 2
0
    def test_no_emails(self, mock_fs):
        mock_fs.emails.return_value = []
        mock_fs.read_file.return_value = '{{placeholder}}'

        placeholder.generate_config(self.settings)

        self.assertFalse(mock_fs.save_file.called)
Exemplo n.º 3
0
    def test_no_emails(self, mock_reader, mock_fs):
        mock_fs.emails.return_value = []
        mock_reader.read.return_value = ("", {"segment": "{{placeholder}}"}, "")

        placeholder.generate_config(self.settings)

        self.assertFalse(mock_fs.save_file.called)
    def test_happy_path(self, mock_fs):
        mock_fs.emails.return_value = [fs.Email('test_name', 'en', 'path', 'full_path')]
        mock_fs.read_file.return_value = '{{placeholder}}'

        placeholder.generate_config(self.settings, None)

        mock_fs.save_file.assert_called_with(
            '{"test_name": {"placeholder": 1}}', 'test_src', 'placeholders_config.json')
Exemplo n.º 5
0
    def test_happy_path(self, mock_reader, mock_fs):
        mock_fs.emails.return_value = [fs.Email("test_name", "en", "path", "full_path")]
        mock_reader.read.return_value = ("", {"segment": "{{placeholder}}"}, "")

        placeholder.generate_config(self.settings, None)

        mock_fs.save_file.assert_called_with(
            '{"test_name": {"placeholder": 1}}', "test_src", "placeholders_config.json"
        )
    def test_use_default_language_to_count_placeholders(self, mock_fs):
        mock_fs.emails.return_value = [
            fs.Email('test_name', 'en', 'path', 'full_path'),
            fs.Email('test_name', 'de', 'path', 'full_path')
        ]
        mock_fs.read_file.side_effect = iter(['{{placeholder}}', '{{placeholder}}{{extra_placeholder}}'])

        placeholder.generate_config(self.settings, None)

        mock_fs.save_file.assert_called_with(
            '{"test_name": {"placeholder": 1}}', 'test_src', 'placeholders_config.json')
Exemplo n.º 7
0
    def test_happy_path(self, mock_fs):
        mock_fs.emails.return_value = [
            fs.Email('test_name', 'en', 'path', 'full_path')
        ]
        mock_fs.read_file.return_value = '{{placeholder}}'

        placeholder.generate_config(self.settings, None)

        mock_fs.save_file.assert_called_with(
            '{"test_name": {"placeholder": 1}}', 'test_src',
            'placeholders_config.json')
Exemplo n.º 8
0
    def test_use_default_language_to_count_placeholders(self, mock_fs):
        mock_fs.emails.return_value = [
            fs.Email('test_name', 'en', 'path', 'full_path'),
            fs.Email('test_name', 'de', 'path', 'full_path')
        ]
        mock_fs.read_file.side_effect = iter(
            ['{{placeholder}}', '{{placeholder}}{{extra_placeholder}}'])

        placeholder.generate_config(self.settings, None)

        mock_fs.save_file.assert_called_with(
            '{"test_name": {"placeholder": 1}}', 'test_src',
            'placeholders_config.json')
Exemplo n.º 9
0
    def test_use_default_language_to_count_placeholders(self, mock_reader, mock_fs):
        mock_fs.emails.return_value = [
            fs.Email("test_name", "en", "path", "full_path"),
            fs.Email("test_name", "de", "path", "full_path"),
        ]
        mock_reader.read.side_effect = iter(
            [("", {"segment": "{{placeholder}}"}, ""), ("", {"segment:" "{{placeholder}}{{extra_placeholder}}"}, "")]
        )

        placeholder.generate_config(self.settings, None)

        mock_fs.save_file.assert_called_with(
            '{"test_name": {"placeholder": 1}}', "test_src", "placeholders_config.json"
        )
Exemplo n.º 10
0
 def test_happy_path(self):
     self.mock_fs.emails.return_value = iter(
         [Email('test_name', 'en', 'path')])
     self.mock_reader.read.return_value = ('', {
         'segment':
         Placeholder('segment', '{{placeholder}}')
     })
     config = placeholder.generate_config('.')
     self.assertEqual(config, {'test_name': Counter({'placeholder': 1})})
Exemplo n.º 11
0
 def test_no_emails(self):
     self.mock_fs.emails.return_value = iter([])
     config = placeholder.generate_config('.')
     self.assertEqual(config, {})