def get(self): try: db = DBConnection() planets = db.retrieve_all_planets() for planet in planets: planet['films'] = fetch_films(planet['planet_name']) self.write({'planets': planets}) except Exception as e: logger.exception("Planets::get") raise Exception('Error to get all planets')
def test_retrieve_all_planets(self): planet1 = { "planet_id": 'yyyyyyyyyyy', "planet_name": "Marcela", "terrain": "Arenoso", "climate": "Deserto" } planet2 = { "planet_id": 'xxxxxxxxxxxx', "planet_name": "Renata", "terrain": "Arenoso", "climate": "Deserto" } table = self.create_table() table.put_item(Item=planet1) table.put_item(Item=planet2) db = DBConnection() response = db.retrieve_all_planets() print(response) self.assertEquals(response[0], planet1) self.assertEquals(response[1], planet2)