コード例 #1
0
    def test_save_category(self):
        query = Category(category=v.category2)
        query.save()

        query2 = Category.objects.get(category=v.category2)
        self.assertEqual(query.__str__(), v.category2)
コード例 #2
0
    def test_update_category(self):
        query = Category(id=self.category0.id, category=v.category2)
        query.save()

        query2 = Category.objects.get(category=v.category2)
        self.assertEqual(query2.id, self.category0.id)
コード例 #3
0
 def test_save_category_confilict(self):
     with self.assertRaises(IntegrityError):
         query = Category(category=self.category0.category)
         query.save()