Exemplo n.º 1
0
    def test_saving_and_retriving_items(self):
        list_ = List()
        list_.save()

        first_item = Item()
        first_item.text = 'The first (ever) list item'
        first_item.priority = "Prioridade Alta"
        first_item.list = list_
        first_item.save()

        second_item = Item()
        second_item.text = 'Item the second'
        second_item.priority = "Prioridade Baixa"
        second_item.list = list_
        second_item.save()

        saved_list = List.objects.first()
        self.assertEquals(saved_list, list_)

        saved_items = Item.objects.all()
        self.assertEquals(saved_items.count(), 2)

        first_saved_item = saved_items[0]
        second_saved_item = saved_items[1]

        self.assertEquals(first_saved_item.text, 'The first (ever) list item')
        self.assertEquals(first_item.priority, "Prioridade Alta")
        self.assertEquals(first_saved_item.list, list_)
        self.assertEquals(second_saved_item.text, 'Item the second')
        self.assertEquals(second_saved_item.priority, "Prioridade Baixa")
        self.assertEquals(second_saved_item.list, list_)
Exemplo n.º 2
0
    def test_saving_and_retriving_items(self):
        list_ = List()  #
        list_.save()  #

        first_item = Item()
        first_item.text = 'The first (ever) list item'
        first_item.priority = 'prioridade baixa'
        first_item.list = list_  #
        first_item.save()

        second_item = Item()
        second_item.text = 'Item the second'
        second_item.priority = 'prioridade alta'
        second_item.list = list_  #
        second_item.save()

        saved_list = List.objects.first()  #
        self.assertEquals(saved_list, list_)  #

        saved_items = Item.objects.all()
        self.assertEquals(saved_items.count(), 2)

        first_saved_item = saved_items[0]
        second_saved_item = saved_items[1]

        self.assertEquals(first_saved_item.text, 'The first (ever) list item')
        self.assertEquals(second_saved_item.text, 'Item the second')
        self.assertEquals(first_saved_item.priority, 'prioridade baixa')
        self.assertEquals(second_saved_item.priority, 'prioridade alta')
        self.assertEquals(first_saved_item.list, list_)  #
        self.assertEquals(second_saved_item.list, list_)  #