def init_db(): db = get_db() """ inventario = [["+5 Dexterity Vest", 10, 20], ["Aged Brie", 2, 0], ["Elixir of the Mongoose", 5, 7], ["Sulfuras, Hand of Ragnaros", 0, 80], ["Sulfuras, Hand of Ragnaros", -1, 80], ["Backstage passes to a TAFKAL80ETC concert", 15, 20], ["Backstage passes to a TAFKAL80ETC concert", 10, 49], ["Backstage passes to a TAFKAL80ETC concert", 5, 49], # ["Conjured Mana Cake", 3, 6] ] """ # Cargamos los items del fichero de texto # con los casos test inventario = Factory.loadInventario() # Poblamos la bbdd # Item de mongoengine es la coleccion for product in inventario: Item(name=product[0], sell_in=product[1], quality=product[2]).save()
def initdb(): inventario = [ ["+5 Dexterity Vest", 10, 20], ["Aged Brie", 2, 0], ["Elixir of the Mongoose", 5, 7], ["Sulfuras, Hand of Ragnaros", 0, 80], ["Sulfuras, Hand of Ragnaros", -1, 80], ["Backstage passes to a TAFKAL80ETC concert", 15, 20], ["Backstage passes to a TAFKAL80ETC concert", 10, 49], ["Backstage passes to a TAFKAL80ETC concert", 5, 49], # ["Conjured Mana Cake", 3, 6] ] for product in inventario: item = Item(name=product[0]) item.sell_in = product[1] item.quality = product[2] item.save()
def get(self): # return {'Welcome!': 'Ollivanders'} return Item.objects().to_json()