def test_serialize(self): mealMenuContainer = MealMenuContainer(main="Main", pastaOrRice="PastaOrRice", soup="Soup", extra1="Extra1", extra2="Extra2", extra3="Extra3") serialized = mealMenuContainer.serialize() self.assertEqual(serialized[0], "Main") self.assertEqual(serialized[5], "Extra3")
def test_toJson(self): mealMenuContainer = MealMenuContainer(main="Main", pastaOrRice="PastaOrRice", soup="Soup", extra1="Extra1", extra2="Extra2", extra3="Extra3") jsonified = mealMenuContainer.toJson() self.assertEqual(jsonified['main'], "Main") self.assertEqual(jsonified['extra3'], "Extra3")
def _testSetup(self): mealMenuContainerTr = MealMenuContainer( main="Ana", pastaOrRice="Pilav ya da makarna", soup="Corba", extra1="Eks1", extra2="Eks2", extra3="Eks3") mealMenuContainerEn = MealMenuContainer( main="Main", pastaOrRice="PastaOrRice", soup="Soup", extra1="Extra1", extra2="Extra2", extra3="Extra3") mealDetailsContainer = MealDetailsContainer( start=datetime(year=2016, month=10, day=27, hour=13), end=datetime(year=2016, month=10, day=27, hour=14), en_name="EnName", tr_name="TrName", en_menu=mealMenuContainerEn, tr_menu=mealMenuContainerTr ) self.mealContainer = MealContainer( datetime(year=2016, month=10, day=27, hour=14), mealDetailsContainer )
def _iterateRow(self, rowNumber, iterationMethod): valid = self._IsRowValid(rowNumber) if not valid: return None else: pass if iterationMethod == "dictionary": meal = {} day = int(self.ws['A' + str(rowNumber)].value) month = int(self.ws['B' + str(rowNumber)].value) year = int(self.ws['C' + str(rowNumber)].value) start_time = self.ws['D' + str(rowNumber)].value end_time = self.ws['E' + str(rowNumber)].value meal['startTime'] = datetime(year=year, month=month, day=day, hour=start_time.hour, minute=start_time.minute) meal['endTime'] = datetime(year=year, month=month, day=day, hour=end_time.hour, minute=end_time.minute) meal['tr_name'] = self.ws['F' + str(rowNumber)].value meal['en_name'] = self.ws['G' + str(rowNumber)].value dishes = {} dish = {} dish['tr_name'] = self.ws['L' + str(rowNumber)].value dish['en_name'] = self.ws['M' + str(rowNumber)].value dish['proteinGrams'] = self.ws['N' + str(rowNumber)].value dish['calorie'] = self.ws['O' + str(rowNumber)].value dishes['main'] = dish dish = {} dish['tr_name'] = self.ws['P' + str(rowNumber)].value dish['en_name'] = self.ws['Q' + str(rowNumber)].value dish['proteinGrams'] = self.ws['R' + str(rowNumber)].value dish['calorie'] = self.ws['S' + str(rowNumber)].value dishes['side'] = dish dish = {} dish['tr_name'] = self.ws['H' + str(rowNumber)].value dish['en_name'] = self.ws['I' + str(rowNumber)].value dish['proteinGrams'] = self.ws['J' + str(rowNumber)].value dish['calorie'] = self.ws['K' + str(rowNumber)].value dishes['soup'] = dish dishes['extras'] = [] dish = {} dish['tr_name'] = self.ws['T' + str(rowNumber)].value dish['en_name'] = self.ws['U' + str(rowNumber)].value dish['proteinGrams'] = self.ws['V' + str(rowNumber)].value dish['calorie'] = self.ws['W' + str(rowNumber)].value dishes['extras'].append(dish) dish = {} dish['tr_name'] = self.ws['X' + str(rowNumber)].value dish['en_name'] = self.ws['Y' + str(rowNumber)].value dish['proteinGrams'] = self.ws['Z' + str(rowNumber)].value dish['calorie'] = self.ws['AA' + str(rowNumber)].value dishes['extras'].append(dish) meal['dishes'] = dishes return meal elif iterationMethod == "asObject": day = int(self.ws['A' + str(rowNumber)].value) month = int(self.ws['B' + str(rowNumber)].value) year = int(self.ws['C' + str(rowNumber)].value) start_time = self.ws['D' + str(rowNumber)].value end_time = self.ws['E' + str(rowNumber)].value trMealMenuContainer = MealMenuContainer( main=self.ws['J' + str(rowNumber)].value, pastaOrRice=self.ws['L' + str(rowNumber)].value, soup=self.ws['H' + str(rowNumber)].value, extra1=self.ws['N' + str(rowNumber)].value, extra2=self.ws['P' + str(rowNumber)].value, extra3=None) enMealMenuContainer = MealMenuContainer( main=self.ws['K' + str(rowNumber)].value, pastaOrRice=self.ws['M' + str(rowNumber)].value, soup=self.ws['I' + str(rowNumber)].value, extra1=self.ws['O' + str(rowNumber)].value, extra2=self.ws['Q' + str(rowNumber)].value, extra3=None) mealDetailsContainer = MealDetailsContainer( start=datetime(year=year, month=month, day=day, hour=start_time.hour, minute=start_time.minute), end=datetime(year=year, month=month, day=day, hour=end_time.hour, minute=end_time.minute), en_name=self.ws['G' + str(rowNumber)].value, tr_name=self.ws['F' + str(rowNumber)].value, en_menu=enMealMenuContainer, tr_menu=trMealMenuContainer) meal = MealContainer(mealDetailsContainer=mealDetailsContainer, date=mealDetailsContainer.end) return meal
def _iterateRow(self, rowNumber, iterationMethod): valid = self._IsRowValid(rowNumber) if not valid: return None else: pass if iterationMethod == "dictionary": meal = {} day = int(self.ws['A' + str(rowNumber)].value) month = int(self.ws['B' + str(rowNumber)].value) year = int(self.ws['C' + str(rowNumber)].value) start_time = self.ws['D' + str(rowNumber)].value end_time = self.ws['E' + str(rowNumber)].value meal['startTime'] = str(year) + '-' + str(month) + '-' + str(day) + 'T' + str(start_time) meal['endTime'] = str(year) + '-' + str(month) + '-' + str(day) + 'T' + str(end_time) meal['tr_type'] = self.ws['F'+str(rowNumber)].value meal['en_type'] = self.ws['G'+str(rowNumber)].value meal['tr_name'] = self.ws['H'+str(rowNumber)].value meal['en_name'] = self.ws['I'+str(rowNumber)].value meal['calorie'] = self.ws['J'+str(rowNumber)].value meal['protein'] = self.ws['K'+str(rowNumber)].value meal['food_type'] = self.ws['L'+str(rowNumber)].value return meal elif iterationMethod == "asObject": day = int(self.ws['A'+str(rowNumber)].value) month = int(self.ws['B'+str(rowNumber)].value) year = int(self.ws['C'+str(rowNumber)].value) start_time = self.ws['D'+str(rowNumber)].value end_time = self.ws['E'+str(rowNumber)].value trMealMenuContainer = MealMenuContainer( main=self.ws['J'+str(rowNumber)].value, pastaOrRice=self.ws['L'+str(rowNumber)].value, soup=self.ws['H'+str(rowNumber)].value, extra1=self.ws['N'+str(rowNumber)].value, extra2=self.ws['P'+str(rowNumber)].value, extra3=None ) enMealMenuContainer = MealMenuContainer( main=self.ws['K'+str(rowNumber)].value, pastaOrRice=self.ws['M'+str(rowNumber)].value, soup=self.ws['I'+str(rowNumber)].value, extra1=self.ws['O'+str(rowNumber)].value, extra2=self.ws['Q'+str(rowNumber)].value, extra3=None ) mealDetailsContainer = MealDetailsContainer( start=datetime(year = year, month = month, day = day, hour = start_time.hour, minute = start_time.minute), end=datetime(year = year, month = month, day = day, hour = end_time.hour, minute = end_time.minute), en_name=self.ws['G'+str(rowNumber)].value, tr_name=self.ws['F'+str(rowNumber)].value, en_menu=enMealMenuContainer, tr_menu=trMealMenuContainer ) meal = MealContainer( mealDetailsContainer=mealDetailsContainer, date=mealDetailsContainer.end ) return meal