def handle_save_grouping_file(self):
     filename = self._view.show_file_save_browser_and_return_selection()
     if filename != "":
         xml_utils.save_grouping_to_XML(
             self._model.groups,
             self._model.pairs,
             filename,
             description=self._view.get_description_text())
Example #2
0
    def test_that_save_and_load_grouping_xml_correctly_stores_and_reads_period_data(self, mock_file_parse):
        groups = [MuonGroup('fwd', [1,2,3], [1,3]), MuonGroup('bwd', [4,5,6], [2,4])]
        pairs = [MuonPair('long', 'fwd', 'bwd')]

        xml_tree = save_grouping_to_XML(groups, pairs, 'filename.xml', save=False, description='Bespoke grouping')
        mock_file_parse.return_value = xml_tree

        loaded_groups, loaded_pairs, loaded_description, loaded_default = load_grouping_from_XML('filename.xml')

        self.assertEqual(loaded_groups[0].periods, groups[0].periods)
        self.assertEqual(loaded_groups[1].periods, groups[1].periods)