def testOrderEditBadOrderId(self):
     request = self.MockRequest()
     request.POST = {
         'SUBMIT': 'Submit and proceed to fulfillment (Staff only)',
     }
     r, d = order._OrderEditInternal(request, {}, 99)
     self.assertTrue(isinstance(r, order.http.HttpResponseRedirect))
     o = list(order.models.Order.all())
     self.assertEquals(1, len(o))
     saved_o = o[0]
     self.assertEquals(0., saved_o.GrandTotal())
 def testOrderEditBadOrderId(self):
     request = self.MockRequest()
     request.POST = {
         'SUBMIT': 'Submit and proceed to fulfillment (Staff only)',
         }
     r, d = order._OrderEditInternal(request, {}, 99)
     self.assertTrue(isinstance(r, order.http.HttpResponseRedirect))
     o = list(order.models.Order.all())
     self.assertEquals(1, len(o))
     saved_o = o[0]
     self.assertEquals(0., saved_o.GrandTotal())
 def testOrderEditGoodOrderIdNewOrder(self):
     request = self.MockRequest()
     request.POST = {
         'submit': 'Start New Order',
     }
     request.FILES = {}
     r, d = order._OrderEditInternal(request, {}, self.order_id)
     self.assertEquals(d['order'], self.order)
     o = list(order.models.Order.all())
     self.assertEquals(1, len(o))
     saved_o = o[0]
     self.assertEquals(0., saved_o.GrandTotal())
 def testOrderEditGoodOrderIdNewOrder(self):
     request = self.MockRequest()
     request.POST = {
         'submit': 'Start New Order',
         }
     request.FILES = {}
     r, d = order._OrderEditInternal(request, {}, self.order_id)
     self.assertEquals(d['order'], self.order)
     o = list(order.models.Order.all())
     self.assertEquals(1, len(o))
     saved_o = o[0]
     self.assertEquals(0., saved_o.GrandTotal())
 def testOrderEditGoodOrderIdOther(self):
     request = self.MockRequest()
     request.POST = {
         'submit': 'Submit this order',
         }
     self.oi = models.OrderItem(order=self.order, item=self.i, 
                                supplier=self.s, quantity=9)
     self.oi.put()
     request.POST['item_%s' % self.oi.key()] = '100'
     request.FILES = {}
     r, d = order._OrderEditInternal(request, {}, self.order_id)
     self.assertTrue(isinstance(r, order.http.HttpResponseRedirect))
     self.assertEquals('/room/order/logistics/%d/' % self.order_id, 
                       r['Location'])
     o = list(order.models.Order.all())
     self.assertEquals(1, len(o))
     saved_o = o[0]
     self.assertEquals(5462.5, saved_o.GrandTotal())
     oi = list(models.OrderItem.all().filter('order =', self.order.key()))
     self.assertEquals(1, len(oi))
 def testOrderEditGoodOrderIdOther(self):
     request = self.MockRequest()
     request.POST = {
         'submit': 'Submit this order',
     }
     self.oi = models.OrderItem(order=self.order,
                                item=self.i,
                                supplier=self.s,
                                quantity=9)
     self.oi.put()
     request.POST['item_%s' % self.oi.key()] = '100'
     request.FILES = {}
     r, d = order._OrderEditInternal(request, {}, self.order_id)
     self.assertTrue(isinstance(r, order.http.HttpResponseRedirect))
     self.assertEquals('/room/order/logistics/%d/' % self.order_id,
                       r['Location'])
     o = list(order.models.Order.all())
     self.assertEquals(1, len(o))
     saved_o = o[0]
     self.assertEquals(5462.5, saved_o.GrandTotal())
     oi = list(models.OrderItem.all().filter('order =', self.order.key()))
     self.assertEquals(1, len(oi))