def setUp(self): self.frankenweenie_data = { "title": "Frankenweenie", "year": 2012, "director": "Tim Burton" } self.interstellar_data = { "title": "Interstellar", "year": 2014, "director": "Christopher Nolan" } self.movie_model = Movies()
class MoviesModelTest(unittest.TestCase): def setUp(self): self.a_movie_data = {} self.other_movie_data = {} self.movie_model = Movies() def tearDown(self): pass def test_get_movie_nonexisting(self): result = self.movie_model.get_movie(1) assert_that(result).is_false() def test_get_movie_existing(self): self.movie_model.create_movie(self.a_movie_data) result = self.movie_model.get_movie(1) assert_that(result).contains_key('id') def test_create_movie_different_ids(self): a_movie = self.movie_model.create_movie(self.a_movie_data) other_movie = self.movie_model.create_movie(self.other_movie_data) assert_that(a_movie['id']).is_not_equal_to(other_movie['id']) def test_create_movie_does_not_alter_data(self): moviedata = {} self.movie_model.create_movie(moviedata) assert_that(moviedata).does_not_contain_key('id')
def setUp(self): self.a_movie_data = {} self.other_movie_data = {} self.movie_model = Movies(3600, Mongo('movies'))
class MoviesModelTest(unittest.TestCase): def setUp(self): self.a_movie_data = {} self.other_movie_data = {} self.movie_model = Movies(3600, Mongo('movies')) def tearDown(self): pass def test_get_movie_nonexisting(self): result = self.movie_model.get_movie(6) if type(result) is bool: assert_that(result).is_equal_to(False) else: assert_that(type(result)).is_equal_to(dict) def test_get_movie_existing_false(self): self.movie_model.create_movie(self.a_movie_data) result = self.movie_model.get_movie(6) assert_that(result).is_not_equal_to(False) def test_create_movie_different_ids(self): a_movie = self.movie_model.create_movie(self.a_movie_data) other_movie = self.movie_model.create_movie(self.other_movie_data) self.assertFalse(a_movie['id'] == other_movie['id']) def test_create_movie_does_not_alter_data(self): moviedata = {} self.movie_model.create_movie(moviedata) assert_that(moviedata).does_not_contain_key('id') def test_get_movie_id_1(self): data = '{"Title":"Frankenweenie","Year":"2012","Rated":"PG","Released":"05 Oct 2012","Runtime":"87 min","Genre":"Animation, Comedy, Family","Director":"Tim Burton","Writer":"Leonard Ripps, Tim Burton (original idea), John August (screenplay)","Actors":"Catherine O\'Hara, Martin Short, Martin Landau, Charlie Tahan","Plot":"Young Victor conducts a science experiment to bring his beloved dog Sparky back to life, only to face unintended, sometimes monstrous, consequences.","Language":"English","Country":"USA","Awards":"Nominated for 1 Oscar. Another 11 wins & 47 nominations.","Poster":"https://images-na.ssl-images-amazon.com/images/M/MV5BMTk1MjYzMjY2N15BMl5BanBnXkFtZTgwNzg2NjAwMzE@._V1_SX300.jpg","Metascore":"74","imdbRating":"7.0","imdbVotes":"75,188","imdbID":"tt1142977","Type":"movie","Response":"True"}' self.movie_model.create_movie(data) assert_that(self.movie_model.get_movie(6)).is_not_equal_to(None)
def setUp(self): self.a_movie_data = {"title": "Planet of the Apes", "year": 2001, "director": "Tim Burton"} self.other_movie_data = {"title": "Frankenweenie - Ebcsont beforr", "year": 2012, "director": "Tim Burton"} self.movie_model = Movies()
class MoviesModelTest(unittest.TestCase): def setUp(self): self.a_movie_data = {"title": "Planet of the Apes", "year": 2001, "director": "Tim Burton"} self.other_movie_data = {"title": "Frankenweenie - Ebcsont beforr", "year": 2012, "director": "Tim Burton"} self.movie_model = Movies() def tearDown(self): pass def test_get_movie_nonexisting(self): result = self.movie_model.get_movie(1) assert_that(result).is_false() def test_get_movie_existing(self): self.movie_model.create_movie(self.a_movie_data) result = self.movie_model.get_movie(1) assert_that(result).contains_key('id') def test_create_movie_different_ids(self): a_movie = self.movie_model.create_movie(self.a_movie_data) other_movie = self.movie_model.create_movie(self.other_movie_data) assert_that(a_movie['id']).is_not_equal_to(other_movie['id']) def test_create_movie_does_not_alter_data(self): moviedata = {} self.movie_model.create_movie(moviedata) assert_that(moviedata).does_not_contain_key('id') def test_update_movie_what_nonexisting(self): result = self.movie_model.update_movie(1, self.a_movie_data) assert_that(result).is_false() def test_update_movie_what_existing(self): self.movie_model.create_movie(self.a_movie_data) result = self.movie_model.update_movie(1, self.other_movie_data) del result['id'] assert_that(result).is_equal_to(self.other_movie_data) def test_delete_movie_what_nonexisting(self): result = self.movie_model.delete_movie(1) assert_that(result).is_false() def test_delete_movie_what_existing(self): self.movie_model.create_movie(self.a_movie_data) assert_that(self.movie_model.delete_movie(1)).is_true()
def tearDown(self): self.app.application.movies = Movies()
# coding=utf-8 from flask import Flask import os from blueprints.movies import movies from blueprints.series import series from model.movies import Movies from model.series import Series from model.mongo import Mongo app = Flask(__name__) app.cachetime = 3600 # 1 óra app.movies = Movies(app.cachetime, Mongo('movies')) app.series = Series(Mongo('series')) @app.route('/') def hello_world(): return """ <!DOCTYPE html> <html> <head> <title>SZTE - PIANK - @Numichi</title> </head> <body> <h1>SZTE - PIANK - @Numichi</h1> <h2>Homework list:</h2> <ul> <li>1. Homework: Git / GitHub</li> <li>2. Homework: Heroku -> Hello World</li>
from flask import Flask import os from blueprints.movies import movies from blueprints.series import series from model.movies import Movies from model.series import Series app = Flask(__name__) app.movies = Movies() app.series = Series() @app.route('/') def hello_world(): return 'Hello continuous delivery' app.register_blueprint(movies, url_prefix='/movies') app.register_blueprint(series, url_prefix='/series') if __name__ == '__main__': app.run(host='127.0.0.1', port=os.getenv('PORT', None))
class MoviesModelTest(unittest.TestCase): def setUp(self): self.frankenweenie_data = { "title": "Frankenweenie", "year": 2012, "director": "Tim Burton" } self.interstellar_data = { "title": "Interstellar", "year": 2014, "director": "Christopher Nolan" } self.movie_model = Movies() def tearDown(self): pass #################################################################################################################### # Get movie tests #################################################################################################################### def test_get_movie_nonexisting(self): result = self.movie_model.get_movie(1) assert_that(result).is_false() def test_get_movie_existing(self): self.movie_model.create_movie(self.frankenweenie_data) result = self.movie_model.get_movie(1) assert_that(result).contains_key('id') #################################################################################################################### # Create movie tests #################################################################################################################### def test_create_movie_different_ids(self): frankenweenie_movie = self.movie_model.create_movie( self.frankenweenie_data) interstellar_movie = self.movie_model.create_movie( self.interstellar_data) assert_that(frankenweenie_movie['id']).is_not_equal_to( interstellar_movie['id']) def test_create_movie_duplicate(self): res = self.movie_model.create_movie(self.frankenweenie_data) res_duplicate = self.movie_model.create_movie(self.frankenweenie_data) assert_that(res).is_true() assert_that(res_duplicate).is_false() def test_create_movie_does_not_alter_data(self): moviedata = {} self.movie_model.create_movie(moviedata) assert_that(moviedata).does_not_contain_key('id') #################################################################################################################### # Update movie tests #################################################################################################################### def test_update_movie_existing(self): wrong_data = { "title": "Frankenweenieeeeee", "year": 2012, "director": "Tim Burton" } self.movie_model.create_movie(wrong_data) self.movie_model.update_movie(1, self.frankenweenie_data) result = self.movie_model.get_movie(1) assert_that(result['title']).is_equal_to('Frankenweenie') def test_update_movie_nonexisting(self): result = self.movie_model.update_movie(1, self.frankenweenie_data) assert_that(result).is_false() #################################################################################################################### # Delete movie tests #################################################################################################################### def test_delete_movie_existing(self): data = { "title": "Frankenweenie", "year": 2002, "director": "Tim Burton" } self.movie_model.create_movie(data) del_res = self.movie_model.delete_movie(1) get_res = self.movie_model.get_movie(1) assert_that(del_res).is_true() assert_that(get_res).is_false() def test_delete_movie_nonexisting(self): result = self.movie_model.delete_movie(1) assert_that(result).is_false()
def tearDown(self): self.app.application.movies = Movies(3600, Mongo('test'))
def setUp(self): self.a_movie_data = {} self.other_movie_data = {} self.movie_model = Movies()