示例#1
0
 def test_update_pizza(self):
     self.cnx = Client()
     p_id, p_sale = 1 , False
     response1, json1 = post('/slumber/slumber_examples/Pizza/create/',{
             'id':p_id, 'name':'Test P', 'for_sale': True})
     self.assertEqual(response1.status_code, 200)
     pizza = self.cnx.slumber_examples.Pizza.get(pk = p_id)
     self.cnx.slumber_examples.Pizza.update(pizza, for_sale = p_sale)
     pizza = self.cnx.slumber_examples.Pizza.get(pk = p_id)
     self.assertEqual(pizza.for_sale, p_sale)
示例#2
0
 def test_service_configuration_missing_for_remoteforeignkey(self):
     self.user.is_superuser = True
     self.user.save()
     client = Client()
     shop = client.slumber_examples.Shop.create(name="Home", slug='home')
     order = Order(shop=shop)
     order.save()
     self.assertIsNotNone(order.shop)
     cursor = connection.cursor()
     cursor.execute("SELECT shop FROM slumber_examples_order WHERE id=%s",
                    [order.pk])
     row = cursor.fetchone()
     self.assertEquals(row[0], order.shop._url)
     with self.assertRaises(SlumberServiceURLError):
         order2 = Order.objects.get(pk=order.pk)
示例#3
0
 def test_service_configuration_works_for_remoteforeignkey(self):
     self.user.is_superuser = True
     self.user.save()
     client = Client()
     shop = client.pizzas.slumber_examples.Shop.create(name="Home", slug='home')
     order = Order(shop=shop)
     order.save()
     cursor = connection.cursor()
     cursor.execute(
         "SELECT shop FROM slumber_examples_order WHERE id=%s",
         [order.pk])
     row = cursor.fetchone()
     self.assertEquals(row[0],
         'slumber://pizzas/shop/%s/' % shop.id)
     order2 = Order.objects.get(pk=order.pk)
     self.assertEquals(unicode(order2.shop), unicode(order.shop))
     self.assertEquals(order2.shop.id, order.shop.id)
示例#4
0
 def setUp(self):
     super(OrderTests, self).setUp()
     self.pizza = Pizza(name='S1', for_sale=True)
     self.pizza.save()
     self.cnx = Client()
示例#5
0
 def setUp(self):
     super(ShopListTests, self).setUp()
     self.cnx = Client()