예제 #1
0
    def test_edit_TextLabel(self):
        #create a new Text Label
        tl = TextLabel()
        tl.title = 'Historical Context 2'
        tl.biography = False
        tl.main_text = """The massive stained oak table combines forms derived from the
                            Gothic Revival and Arts and Crafts movements of the later
                            19th century. The colour and shape of the table, and of other
                            pieces of furniture, were echoed in interior details throughout
                            the house. Wright believed that wood should be cut simply and
                            stained (never varnished) to reveal the 'nature' of the material."""
        tl.save()

        #bind the object to a portal
        rel = PortalTextLabel(textlabel=tl, portal=Portal.objects.get(id=1))
        rel.save()

        #get the Text Label and set the new title 
        tl = TextLabel.objects.get(id=1)
        replacing_title = 'The stained oak table'
        self.assertNotEqual(tl.title, replacing_title)

        # change the title
        tl.title = replacing_title
        tl.save()
        self.assertEqual(tl.title, replacing_title)

        #test the title has changed in the portal view
        response = self.client.get('/portal/1/')
        self.assertContains(response, """<div class="title"><h2>The stained oak table</h2></div>""", 1, 200)