def test_load_hard_coded_settings(self, mock_messagebar, mock_join,
                                      mock_hardcoded_template):
        self.midvatten.ms.settingsdict['secplot_loaded_template'] = ''
        self.midvatten.ms.settingsdict['secplot_templates'] = ''
        mock_join.return_value = ''
        test_dict = {"hardcoded": 1}
        mock_hardcoded_template.return_value = test_dict

        secplottemplates = PlotTemplates(
            self.sectionplot, self.template_list, self.edit_button,
            self.load_button, self.save_as_button, self.import_button,
            self.remove_button, self.template_folder,
            'secplot_templates', 'secplot_loaded_template',
            defs.secplot_default_template(), self.midvatten.ms)
        test = utils.anything_to_string_representation(
            secplottemplates.loaded_template)
        reference = utils.anything_to_string_representation(test_dict)

        assert call.warning(
            bar_msg=
            'Default template not found, loading hard coded default template.'
        ) in mock_messagebar.mock_calls
        assert call.info(
            log_msg='Loaded template from default hard coded template.'
        ) in mock_messagebar.mock_calls
        assert test == reference
Ejemplo n.º 2
0
 def _test(self, filename, mock_join, mock_messagebar):
     mock_join.return_value = filename
     self.midvatten.ms.settingsdict['secplot_templates'] = filename
     secplottemplates = PlotTemplates(self.sectionplot, self.template_list, self.edit_button,
                                      self.load_button,
                                      self.save_as_button, self.import_button, self.remove_button,
                                      self.template_folder, 'secplot_templates', 'secplot_loaded_template',
                                      defs.secplot_default_template(), self.midvatten.ms)
     return secplottemplates, mock_messagebar
Ejemplo n.º 3
0
    def test_load_from_msettings(self, mock_messagebar):
        test_str = '''{"test": 1}'''
        self.midvatten.ms.settingsdict['secplot_loaded_template'] = test_str
        self.midvatten.ms.settingsdict['secplot_templates'] = ''

        secplottemplates = PlotTemplates(self.sectionplot, self.template_list, self.edit_button, self.load_button,
                                               self.save_as_button, self.import_button, self.remove_button,
                                               self.template_folder, 'secplot_templates', 'secplot_loaded_template',
                                               defs.secplot_default_template(), self.midvatten.ms)

        assert call.info(log_msg='Loaded template from midvatten settings secplot_loaded_template.') in mock_messagebar.mock_calls
        assert utils.anything_to_string_representation(secplottemplates.loaded_template) == test_str
Ejemplo n.º 4
0
            def _test(self, filename, mock_join, mock_messagebar, mock_select_files):
                mock_join.return_value = ''
                mock_select_files.return_value = [filename]
                self.midvatten.ms.settingsdict['secplot_templates'] = ''
                secplottemplates = PlotTemplates(self.sectionplot, self.template_list, self.edit_button,
                                                 self.load_button,
                                                 self.save_as_button, self.import_button, self.remove_button,
                                                 self.template_folder, 'secplot_templates', 'secplot_loaded_template',
                                                 defs.secplot_default_template(), self.midvatten.ms)
                secplottemplates.import_templates()
                item = [self.template_list.item(idx) for idx in range(self.template_list.count())][0]
                item.setSelected(True)
                secplottemplates.load()

                return secplottemplates, mock_messagebar, filename
    def test_load_hard_coded_settings(self, mock_messagebar, mock_join, mock_hardcoded_template):
        self.midvatten.ms.settingsdict['secplot_loaded_template'] = ''
        self.midvatten.ms.settingsdict['secplot_templates'] = ''
        mock_join.return_value = ''
        test_dict = {"hardcoded": 1}
        mock_hardcoded_template.return_value = test_dict

        secplottemplates = PlotTemplates(self.sectionplot, self.template_list, self.edit_button,
                                         self.load_button,
                                         self.save_as_button, self.import_button, self.remove_button,
                                         self.template_folder, 'secplot_templates', 'secplot_loaded_template',
                                         defs.secplot_default_template(), self.midvatten.ms)
        test = utils.anything_to_string_representation(secplottemplates.loaded_template)
        reference = utils.anything_to_string_representation(test_dict)

        assert call.warning(bar_msg='Default template not found, loading hard coded default template.') in mock_messagebar.mock_calls
        assert call.info(log_msg='Loaded template from default hard coded template.') in mock_messagebar.mock_calls
        assert test == reference
 def test_secplot_default_template(self):
     adict = defs.secplot_default_template()
     assert isinstance(adict, dict)
     assert adict
 def test_secplot_default_template(self):
     adict = defs.secplot_default_template()
     assert isinstance(adict, dict)
     assert adict