示例#1
0
 def testFilterLogging(self):
     '''
     Order must log the ProductOrder that was filtered and the reson why thy were
     filtered.
     '''
     log =Log()
     order1 = Order(log)
     order2 = Order(log)
     order1.loadOrder(os.path.join(TEST_FILE_ROOT, 'OrderTestFile2.xls'))
     order2.loadOrder(os.path.join(TEST_FILE_ROOT, 'OrderTestFile3.xls'))
     order1.filter(order2)
     self.assertListEqual(log.getMsgList(), self.ATTENDED_LOG, 'Order failed to log the filtered ProductOrder.')
示例#2
0
 def testFilterOrder(self):
     '''
     Order must be able to filter and remove the bad ProductOrder and those
     already ordered.
     The filters are:
         - imcomplete or incoherent ProductOrder.
         - Already ordered in the last 20 days ProductOrder, except if employee is the admin.
     '''
     log =Log()
     order1 = Order(log)
     order2 = Order(log)
     order1.loadOrder(os.path.join(TEST_FILE_ROOT, 'OrderTestFile2.xls'))
     order2.loadOrder(os.path.join(TEST_FILE_ROOT, 'OrderTestFile3.xls'))
     order1.filter(order2)
     result = []
     for i in range(len(order1)):
         result.append(order1.popLeft())
     i = i
     self.assertListEqual(result, self.ATTENDED_RESULTS, 'Order failed to filter and remove the bad and already ordered ProductOrder.')
示例#3
0
dailyOrder = Order(log)
previousOrder = Order(log)
try:
    dailyOrder.loadOrder(dailyOrderFile)
except:
    #if nothing to order, simply log it and exit
    log.logMsg(u'Rien a commander.')
    log.outputLog(outputPath)
    sys.exit(0)
try:
    previousOrder.loadOrder(previousOrderFile)
except:
    pass

#filter the daily order data
dailyOrder.filter(previousOrder)

#generate the mail
if dailyOrder.getOrderList():
    orderMail = OrderMail('*****@*****.**', '[email protected];[email protected]')
    for order in dailyOrder.getOrderList():
        orderMail.addLineToBody(order.getProductOrderStr())
    orderMail.generate()
    
    #transfert data to previousOrder and clean up dailyOrder
    for i in range(len(dailyOrder)):
        previousOrder.append(dailyOrder.popLeft())
    dailyOrder.save(dailyOrderFile)
    previousOrder.save(previousOrderFile)
        
    #notify that the mail is ready to send