def test_no_graphs_in_container(self, mock_get_graph_ids):
     """Return empty list if graph_ids list is empty
     """
     mock_get_graph_ids.return_value = []
     gwyfile = Mock(spec=Gwyfile)
     graphs = GwyContainer._dump_graphs(gwyfile)
     self.assertEqual(graphs, [])
 def test_getting_gwygraphmodel_objects(self,
                                        mock_get_graph_ids,
                                        mock_GwyGraphModel):
     """Get <GwyGraphModel*> objects and their visibility flags
        from Gwyfile object
     """
     graph_ids = [1, 2, 3]
     graph_keys = ["/0/graph/graph/{:d}".format(graph_id)
                   for graph_id in graph_ids]
     graph_vis_keys = ["/0/graph/graph/{:d}/visible".format(graph_id)
                       for graph_id in graph_ids]
     mock_get_graph_ids.return_value = graph_ids
     gwyfile = Mock(spec=Gwyfile)
     GwyContainer._dump_graphs(gwyfile)
     gwyfile.get_gwyitem_object.assert_has_calls(
         [call(graph_key) for graph_key in graph_keys])
     gwyfile.get_gwyitem_bool.assert_has_calls(
         [call(graph_vis_key) for graph_vis_key in graph_vis_keys])
 def test_returned_value(self,
                         mock_get_graph_ids,
                         mock_GwyGraphModel):
     """Convert <GwyGraphModel*> object to GwyGraphModel objects
     and return the latter
     """
     graph_ids = [1, 2, 3]
     mock_get_graph_ids.return_value = graph_ids
     gwygraphmodels = [Mock() for graph_id in graph_ids]
     gwyfile = Mock(spec=Gwyfile)
     graphs = GwyContainer._dump_graphs(gwyfile)
     self.assertListEqual(graphs,
                          [mock_GwyGraphModel(gwygraphmodel)
                           for gwygraphmodel in gwygraphmodels])