def test_retrieve_planet_not_found(self):
        planet_id = 'yyyyyyyyyyy'
        planet = {
            "planet_id": planet_id,
        	"planet_name": "Marcela",
        	"terrain": "Arenoso",
        	"climate": "Deserto"
        }

        self.create_table()
        db = DBConnection()
        response = db.retrieve_planet('planet_id', planet_id)

        self.assertEquals(response, {})
    def test_retrieve_planet(self):
        planet_id = 'xxxxxxxxxxxx'
        planet = {
            "planet_id": planet_id,
        	"planet_name": "Renata",
        	"terrain": "Arenoso",
        	"climate": "Deserto"
        }

        table = self.create_table()
        table.put_item(Item=planet)
        db = DBConnection()
        response = db.retrieve_planet('planet_id', planet_id)

        self.assertEquals(response, planet)
Пример #3
0
    def get(self):
        try:
            search_by = self.get_argument("search_by")
            value = self.get_argument("value")

            db = DBConnection()
            planet = db.retrieve_planet(search_by, value)

            if not planet:
                self.set_status(404)
                self.finish("Planet not found")
                return

            planet['films'] = fetch_films(planet['planet_name'])
            self.write({'planet': planet})
        except tornado.web.MissingArgumentError as argError:
            logger.exception("SearchPlanet::get")
            raise argError
        except Exception as e:
            logger.exception("SearchPlanet::get")
            raise Exception('Error to search planet')