~trb143/openlp/more_media

« back to all changes in this revision

Viewing changes to tests/functional/openlp_core/ui/test_thememanager.py

  • Committer: Tim Bentley
  • Date: 2019-06-11 18:08:21 UTC
  • mfrom: (2876.1.2 openlp)
  • Revision ID: tim.bentley@gmail.com-20190611180821-m0viu2wi93p2o97k
Head

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
 
84
84
    @patch('openlp.core.ui.thememanager.shutil')
85
85
    @patch('openlp.core.ui.thememanager.create_paths')
86
 
    def test_write_theme_same_image(self, mocked_create_paths, mocked_shutil):
 
86
    def test_save_theme_same_image(self, mocked_create_paths, mocked_shutil):
87
87
        """
88
88
        Test that we don't try to overwrite a theme background image with itself
89
89
        """
98
98
        mocked_theme.extract_formatted_xml = MagicMock()
99
99
        mocked_theme.extract_formatted_xml.return_value = 'fake_theme_xml'.encode()
100
100
 
101
 
        # WHEN: Calling _write_theme with path to the same image, but the path written slightly different
 
101
        # WHEN: Calling save_theme with path to the same image, but the path written slightly different
102
102
        file_path_1 = RESOURCE_PATH / 'church.jpg'
103
 
        theme_manager._write_theme(mocked_theme, file_path_1, file_path_1)
 
103
        theme_manager.save_theme(mocked_theme, file_path_1, file_path_1)
104
104
 
105
105
        # THEN: The mocked_copyfile should not have been called
106
106
        assert mocked_shutil.copyfile.called is False, 'copyfile should not be called'
107
107
 
108
108
    @patch('openlp.core.ui.thememanager.shutil')
109
109
    @patch('openlp.core.ui.thememanager.create_paths')
110
 
    def test_write_theme_diff_images(self, mocked_create_paths, mocked_shutil):
 
110
    def test_save_theme_diff_images(self, mocked_create_paths, mocked_shutil):
111
111
        """
112
112
        Test that we do overwrite a theme background image when a new is submitted
113
113
        """
121
121
        mocked_theme.theme_name = 'themename'
122
122
        mocked_theme.filename = "filename"
123
123
 
124
 
        # WHEN: Calling _write_theme with path to different images
 
124
        # WHEN: Calling save_theme with path to different images
125
125
        file_path_1 = RESOURCE_PATH / 'church.jpg'
126
126
        file_path_2 = RESOURCE_PATH / 'church2.jpg'
127
 
        theme_manager._write_theme(mocked_theme, file_path_1, file_path_2)
 
127
        theme_manager.save_theme(mocked_theme, file_path_1, file_path_2)
128
128
 
129
129
        # THEN: The mocked_copyfile should not have been called
130
130
        assert mocked_shutil.copyfile.called is True, 'copyfile should be called'
131
131
 
132
 
    def test_write_theme_special_char_name(self):
 
132
    def test_save_theme_special_char_name(self):
133
133
        """
134
134
        Test that we can save themes with special characters in the name
135
135
        """
142
142
        mocked_theme.theme_name = 'theme 愛 name'
143
143
        mocked_theme.export_theme.return_value = "{}"
144
144
 
145
 
        # WHEN: Calling _write_theme with a theme with a name with special characters in it
146
 
        theme_manager._write_theme(mocked_theme)
 
145
        # WHEN: Calling save_theme with a theme with a name with special characters in it
 
146
        theme_manager.save_theme(mocked_theme)
147
147
 
148
148
        # THEN: It should have been created
149
149
        assert os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')) is True, \