def runTest(self): # Generate an XML file first. days = {} for f in range(20): curtime = datetime.datetime(2005, 6, f + 1, 0, 0, 0, 0, tz.LocalTimezone()) day = Day(curtime) day.set_weight(100) for i in range(20): food = Food("Testfood " + str(i)) food.quantity = 10 + i food.energy = 100 * i food.time = curtime day.add_food(food) days[curtime.ctime()] = day gen = ConsumerDBGenerator() gen.generate(XML_FILE, days) # Now read. db = ConsumerDB() self.parser.setContentHandler(db) self.parser.parse(XML_FILE) assert len(db.getDays()) == 20 os.remove(XML_FILE)
def runTest(self): # Generate an XML file first. foods = {} for i in range(20): food = Food("Testfood " + str(i)) food.energy = 100 * i foods[food.name] = food gen = FoodDBGenerator(); gen.generate(XML_FILE, foods) # Now read. db = FoodDB() self.parser.setContentHandler(db) self.parser.parse(XML_FILE) assert len(db.getFoods()) == 20 os.remove(XML_FILE)
def runTest(self): # Generate an XML file first. days = {} for f in range(20): curtime = datetime.datetime(2005, 6, f + 1, 0, 0, 0, 0, tz.LocalTimezone()) day = Day(curtime) day.set_weight(100) for i in range(20): food = Food("Testfood " + str(i)) food.quantity = 10 + i food.energy = 100 * i food.time = curtime day.add_food(food) days[curtime.ctime()] = day gen = ConsumerDBGenerator(); gen.generate(XML_FILE, days) # Now read. db = ConsumerDB() self.parser.setContentHandler(db) self.parser.parse(XML_FILE) assert len(db.getDays()) == 20 os.remove(XML_FILE)