def test_get_all_nodes_with_max_generation(self):
        """Test get_all_nodes with max_generation."""
        share_dao = SharedDirectory(self.rw_share, by_user=self.sharer)
        sgw = ReadWriteVolumeGateway(self.user, share=share_dao)
        root = sgw.get_root()
        root_id = root.id
        # make dirs and put files in them
        dirs = []
        files = []
        for i in range(10):
            d = sgw.make_subdirectory(root_id, '%sd' % i)
            f = sgw.make_file(d.id, '%sfile.txt' % i)
            dirs.append(d)
            files.append(f)
        nodes = dirs + files
        nodes.append(root)
        # sort them in the right order
        nodes.sort(key=attrgetter('path', 'name'))
        # with a max_generation in the middle
        nodes_gen_10 = sgw.get_all_nodes(max_generation=10)
        self.assertEqual(nodes_gen_10,
                         [n for n in nodes if n.generation <= 10])
        # with the last generation
        nodes_gen_20 = sgw.get_all_nodes(
            max_generation=nodes[-1].generation)
        self.assertEqual(nodes_gen_20, nodes)