Пример #1
0
 def test_key_error_on_update(self, bad_mock):
     """ Test KeyError on update """
     bad_mock.side_effect = KeyError()
     wishlist = Wishlist("fido", "1")
     wishlist.save()
     wishlist.name = 'Fifi'
     wishlist.update()
Пример #2
0
	def test_key_error_on_update(self, bad_mock):
		""" Test KeyError on update """
		bad_mock.side_effect = KeyError()
		wishlist =  Wishlist("joan's wishlist", "joan")
		wishlist.save()
		wishlist.name = "joan's wishlist"
		wishlist.update()
Пример #3
0
	def test_update_a_wishlist(self):
		""" Update a Wishlist """
		wishlist = Wishlist("mike's wishlist", "mike")
		wishlist.save()
		self.assertNotEqual(wishlist.id, None)
		# Change it an save it
		wishlist.name = "mike's hard wishlist"
		wishlist.save()
		# Fetch it back and make sure the id hasn't changed
		# but the data did change
		wishlists = Wishlist.all()
		self.assertEqual(len(wishlists), 1)
		self.assertEqual(wishlists[0].name, "mike's hard wishlist")
Пример #4
0
	def test_update_error(self):
		""" TEST failure of the update try-catch """
		wishlist = Wishlist("mike's wishlist", "mike")
		wishlist.save()
		self.assertNotEqual(wishlist.id, None)
		og_id = wishlist.id

		#change its ID before updating it to trigger try-catch block
		wishlist.id = "asdf123"
		wishlist.name = "mike's hard wishlist"
		wishlist.save()
		# Fetch it back and make sure the id and data hasn't changed
		wishlists = Wishlist.all()
		self.assertEqual(len(wishlists), 1)
		self.assertEqual(wishlists[0].name, "mike's wishlist")
		self.assertEqual(wishlists[0].id, og_id)