def testLogMsg(self): ''' Log must be able to log new messages. ''' log = Log() for msg in self.TEST_VALUES: log.logMsg(msg) self.assertListEqual(log.getMsgList(), self.TEST_VALUES, 'Log isn\'t able to log new messages')
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.')
#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 winsound.PlaySound(os.path.join(audioPath, 'orderingscript.wav'), winsound.SND_FILENAME) #save the log if there's somthing in it if log.getMsgList(): log.outputLog(outputPath) #delete the recuparation file of libre office if os.path.exists(os.path.join(outputPath, '.~lock.a_commander.xls#')): os.remove(os.path.join(outputPath, '.~lock.a_commander.xls#')); if os.path.exists(os.path.join(outputPath, '.~lock.commander.xls#')): os.remove(os.path.join(outputPath, '.~lock.commander.xls#'));