def test_update(self): FilmRepository.create(**self.film_dict) film_update = { "vals": { 'year': 1995, } } response = self.client.put( "/api/film/1", content_type="application/json", data=json.dumps(film_update), ) self.assertEqual(response.status_code, 200) response_json = json.loads(response.data.decode("utf-8")) check_dict = self.film_dict.copy() check_dict['id'] = 1 check_dict['year'] = 1995 self.assertEqual( response_json, {"film": check_dict}, ) film = FilmRepository.get(id=1) self.assertEqual(film.year, 1995)
def test_get(self): FilmRepository.create(**self.film_dict) response = self.client.get("/api/film/1") self.assertEqual(response.status_code, 200) response_json = json.loads(response.data.decode("utf-8")) check_dict = self.film_dict.copy() check_dict['id'] = 1 self.assertEqual( response_json, {"film": check_dict}, )
def post(name, year, pos, rating, url, image): film = FilmRepository.create( name=name, year=year, pos=pos, rating=rating, url=url, image=image, ) return jsonify({"film": film.json})
def post(title, author, date, type, image, synopsis, country): """ Create a film based on the sent information """ film = FilmRepository.create(title=title, author=author, date=date, type=type, image=image, synopsis=synopsis, country=country) return jsonify({"film": film.json})
def test_get(self): FilmRepository.create(**self.film_dict_1) FilmRepository.create(**self.film_dict_2) FilmRepository.create(**self.film_dict_3) response = self.client.get("/api/top/") self.assertEqual(response.status_code, 200) response_json = json.loads(response.data.decode("utf-8")) self.assertEqual( len(response_json.get("films")), 3, )
def post(title, date): """ Create a film based on the sent information """ film = FilmRepository.create(title=title, date=date) return jsonify({"film": film.json})