Friday, 17 December 2010

Thumbnail not saving, part 2

I thought I'd write a test to make sure narratives saved their thumbs correctly. This passes:

        [Test]
        def save_scene_thumb():
#
#               let's have the variables separate
#
                s_name = "scene name"
                s_desc = "scene desc"
                n_name = "narrative name"
                n_desc = "narrative desc"
                s_defl = n_desc
                t_name = "player"
                t_path = "data/images.pc.png"
                t_op = "show"
                t_loc = "left"
#
#               then we can interpolate them into the target string
#
                target = detab("""
                        <scene name="${s_name}" default="${s_defl}" desc="${s_desc}">
                         <narrative name="${n_name}" desc="${n_desc}">
                          <thumb name="${t_name}" path="${t_path}" operation="${t_op}" location="${t_loc}" />
                         </narrative>
                        </scene>
                """)
#
#               ... and use them to initialise the scene
#
                sc = Scene()
                sc.name         = s_name
                sc.default      = s_defl
                sc.desc         = s_desc
                n = sc.Add_narrative(n_name, n_desc)
                t as Thumb = n.Add(Thumb())
                t.name = t_name
                t.path = t_path
                t.operation = t_op
                t.location = t_loc
#
#               now we need a string writer
#
                using sw = StringWriter():
                        sc.save(sw)
                        assert target = "${sw}"


So we can probably rule out a bug in narrative or thumbnail. The next most likelty cause is that the thumbnail is never being added to the narrative. Investigating...


Update:

Got it: Narrative was testing the type of the narrative item and calling class specific save routines. Now that all items have a common base class, we can do this the proper OO way.

No comments: