Пример #1
0
    def setUp(self):
        self.APP = create_app()
        self.client = self.APP.test_client
        self.database_path = "postgresql://*****:*****@localhost:5432/castingagency_test"
        setup_db(self.APP, self.database_path)

        self.headers_casting_assistant = {
            "Content-Type": "application/json",
            "Authorization": f"Bearer {assistant_token}"
        }
        self.headers_casting_director = {
            "Content-Type": "application/json",
            "Authorization": f"Bearer {director_token}"
        }
        self.headers_executive_producer = {
            "Content-Type": "application/json",
            "Authorization": f"Bearer {producer_token}"
        }

        self.new_actor = {
            "name": "Actor TestName",
            "age": 100,
            "gender": "Male/Female"
        }
        self.new_movie = {
            "title": "Movie TestTitle",
            "release_date": "5/18/1990"
        }

        with self.APP.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.APP)
            # create all tables
            self.db.create_all()
Пример #2
0
def create_app(test_config=None):
    # create and configure the app
    app = Flask(__name__)
    setup_db(app)
    CORS(app)

    return app
Пример #3
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client
        self.database_path = os.environ['DATABASE_URL']
        self.headers_casting_assistant = {
            'Content-Type': 'application/json',
            'Authorization':
            'Bearer ' + os.environ.get('CASTING_ASSISTANT_TOKEN')
        }
        self.headers_casting_director = {
            'Content-Type': 'application/json',
            'Authorization':
            'Bearer ' + os.environ.get('CASTING_DIRECTOR_TOKEN')
        }
        self.headers_executive_producer = {
            'Content-Type': 'application/json',
            'Authorization':
            'Bearer ' + os.environ.get('EXECUTIVE_PRODUCER_TOKEN')
        }

        setup_db(self.app, self.database_path)

        self.new_movie = {
            'title': 'The Goonies',
            'release_date': '1985-06-22T00:00:00'
        }
        self.new_actor = {'name': 'Tom Hanks', 'age': '60', 'gender': 'Male'}

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
Пример #4
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = app
        self.client = self.app.test_client
        setup_db(self.app)

        self.producer_token = {
            "Authorization": f"Bearer {os.getenv('producer_token')}"
        }
        self.director_token = {
            "Authorization": f"Bearer {os.getenv('director_token')}"
        }
        self.assistant_token = {
            "Authorization": f"Bearer {os.getenv('assistant_token')}"
        }

        self.new_actor = {
            "name": "new_actor",
            "age": 30,
            "gender": "Male"
        }

        self.new_movie = {
            "title": "new_movie",
            "release_date": '10-12-2020'
        }

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
Пример #5
0
    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client
        self.database_path = test_database_path
        self.castingAssistant = castingAssistant_BearerToken
        self.castingDirector = castingDirector_BearerToken
        self.executiveProducer = executiveProducer_BearerToken

        setup_db(self.app, self.database_path)

        self.new_movie = {"title": "Mad Max", "release_date": "2016-01-10"}
        self.edit_movie = {"title": "Mad Max 2", "release_date": "2020-01-10"}

        self.new_actor = {
            "name": "Denzel Washington",
            "age": "65",
            "gender": "Male",
        }

        self.edit_actor = {"name": "Denzel Washington", "age": 66, "gender": "Male"}

        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()
Пример #6
0
    def setUp(self):
        '''Define test variables and initialize web app'''
        self.app = create_app()
        self.client = self.app.test_client
        self.database_path = os.environ['DATABASE_URL']
        setup_db(self.app, self.database_path)

        self.category = {
            "name": "Testing Category",
            "code": "TESTRND202000100123",
            "mm_min": 5,
            "mm_max": 370,
            "column_min": 1,
            "column_max": 7,
            "notes": "Category for Testing - DO NOT USE"
        }

        self.area = {
            "name": "Testing Area - DO NOT USE",
            "code": "TESTAREARND202000100123",
            "gp_mm_price": 7.00,
            "gp_mm_price_text": 4.00,
            "dp_mm_price": 5.00,
            "dp_mm_price_text": 2.50
        }
Пример #7
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client()
        self.database_name = "capstone_test"
        self.database_path = "postgres://{}/{}".\
            format('udacity:admin@localhost:5433', self.database_name)
        setup_db(self.app, self.database_path)

        self.new_actor = {
            'name': 'lithika',
            'age': 10,
            'gender': 'female'
        }

        self.new_movie = {
            'title': 'Frozen II',
            'releasedate': '12-06-2019'
        }

        self.update_actor = {
            'name': 'Sam'
        }

        self.udpate_movie = {
            'title': 'Cars'
        }

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()
Пример #8
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = app
        self.client = self.app.test_client
        self.database_name = "database.db"
        self.project_dir = os.path.dirname(os.path.abspath(__file__))
        self.database_path = "sqlite:///{}".format(
            os.path.join(self.project_dir, self.database_name))
        setup_db(self.app)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()

        self.casting_assistant_token = os.environ.get(
            'CASTING_ASSISTANT_TOKEN')
        self.casting_director_token = os.environ.get('CASTING_DIRECTOR_TOKEN')
        self.executive_director_token = os.environ.get(
            'EXECUTIVE_DIRECTOR_TOKEN')

        self.update_movie = {
            "title": "Superman",
            "release_date": "09-Nov-2018"
        }

        self.new_movie = {"title": "Inception", "release_date": "11-Apr-2014"}

        self.update_actor = {"name": "Paul", "age": 44, "gender": "Male"}

        self.new_actor = {"name": "Kelvin", "age": 42, "gender": "Male"}

        self.dummy = {"foo": "bar"}
Пример #9
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client
        self.database_path = os.environ['DATABASE_URL']
        self.token = os.environ['ACCESS_TOKEN']
        setup_db(self.app, self.database_path)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()

        self.new_actor = {'name': 'Vin Diesel', 'age': 52, 'gender': 'M'}

        self.new_movie = {
            'title': 'F9: The Fast Saga',
            'release_date': '02/04/2021'
        }

        self.update_actor = {'age': 53}

        self.update_movie = {'release_date': '03/04/2021'}

        self.auth = {"Authorization": self.token}
Пример #10
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = app
        self.client = self.app.test_client
        self.database_name = "castingAgency_test"
        self.database_path = "postgres:///" + self.database_name
        setup_db(self.app, self.database_path)

        self.assistant_token = 'Bearer ' + os.environ['assistant']
        self.director_token = 'Bearer ' + os.environ['director']
        self.producer_token = 'Bearer ' + os.environ['producer']

        self.assistant_header = {
            'Authorization': self.assistant_token
        }

        self.director_header = {
            'Authorization': self.director_token
        }

        self.producer_header = {
            'Authorization': self.producer_token
        }

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()
Пример #11
0
    def setUp(self):
        # Setup Flask App
        self.app = create_app()
        self.appctx = self.app.app_context()
        self.appctx.push()
        self.client = self.app.test_client

        # Setup PostgreSQL database and SQLAlchemy
        self.database_name = "capstone_sudoku_solver"
        self.database_path = "postgresql://{}/{}".format(
            'jordanhuus@localhost:5432', self.database_name)
        setup_db(self.app)

        # Generate test authentication JWT token
        self.admin_jwt_token = get_admin_jwt_token()
        self.gamer_jwt_token = get_gamer_jwt_token()
        with open("api_test_false_token.txt", "r") as file:
            self.false_token = file.read()

        # binds the app to the current context
        with self.appctx:
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()
Пример #12
0
    def setUpClass(self):
        """Define test variables and initialize app."""
        self.app = app
        self.client = self.app.test_client
        self.DATABASE_URL = os.environ['DATABASE_URL']
        setup_db(self.app)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.drop_all()
            self.db.create_all()

        # add 1 team-member
        data = {
            "name": "Julien",
            "position": "tester"
        }
        self.client().post('/team-members', json=data, headers=self.headers_mg)

        # add 1 kudo
        data = {
            "text": "Julien, you've done a great job!",
            "team_member_id": 1,
            "date": "2020-09-12"
        }
        self.client().post('/kudos', json=data, headers=self.headers_mg)
Пример #13
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client
        self.headers= {"Authorization":f"Bearer {os.environ['Executive_Producer_Token']}"}
        self.database_name = "Casting_Agency_Test"
        User = "******"
        self.database_path = "postgres://{}@{}/{}".format(User,'localhost:5432', self.database_name)
        setup_db(self.app, self.database_path)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()
        
        self.new_movie = {
            "title":"MovieA",
            "release_date":"2019-2-22"
        }
        
        self.new_actor = {
            "name":"Saif",
            "age":21,
            "gender":"M",
            "movies_ids":[1]
        }
Пример #14
0
    def setUp(self):
        """Define test variables and initialize app."""

        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = "capstone_test"
        self.database_path = "postgres://{}:{}@{}/{}".format(
            'postgres', '9520099', 'localhost:5432', self.database_name)
        setup_db(self.app, self.database_path)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()

        self.actor = {
            "name": "my new actor added",
            "age": "37",
            "gender": "Female"
        }

        self.movie = {"title": "new movie added", "release": "2020"}

        self.producer_token = os.environ.get('PRODUCER_TOKEN')
        self.director_token = os.environ.get('DIRECTOR_TOKEN')
        self.assistant_token = os.environ.get('ASSISTANT_TOKEN')
Пример #15
0
    def setUp(self):
        self.CASTING_ASSISTANT = os.environ['CASTING_ASSISTANT']
        self.CASTING_DIRECTOR = os.environ['CASTING_DIRECTOR']
        self.EXECUTIVE_PRODUCER = os.environ['EXECUTIVE_PRODUCER']

        self.app = create_app()
        self.client = self.app.test_client
        setup_db(self.app)

        self.new_actor = {
            "name": "William",
            "age": 32,
            "gender": "male"
        }

        self.new_movie = {
            "title": "Dr Strange",
            "duration": 3,
            "release_year": 2016
        }

        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)

            self.db.create_all()
Пример #16
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client()
        self.db_path = os.environ['DATABASE_URL']
        self.token = os.environ['TOKEN_TEST']
        setup_db(self.app, self.db_path)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()

        self.new_actor = {"name": "lithika", "age": 10, "gender": "female"}

        self.new_movie = {"title": "Frozen II", "releasedate": "12-06-2019"}

        self.update_actor = {"name": "Sam"}

        self.update_movie = {"title": "Cars"}

        # Valid Token passed from environment
        self.authorization = {"Authorization": self.token}

        # Invalid Token
        self.authorization_exp = {
            "Authorization":
            "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlJ4MnRCdnd5T2ZNRUdnRVlwX3VoRSJ9.eyJpc3MiOiJodHRwczovL3NoYWxpbmktZnNuZC5hdXRoMC5jb20vIiwic3ViIjoiNUt2Wm45eXhwUEE4WHZWZ1k0MFNFejNBMzJ2N0xWaW1AY2xpZW50cyIsImF1ZCI6IkNhcHN0b25lQVBJIiwiaWF0IjoxNTkwMjUyNjkzLCJleHAiOjE1OTA4NTc0OTMsImF6cCI6IjVLdlpuOXl4cFBBOFh2VmdZNDBTRXozQTMydjdMVmltIiwiZ3R5IjoiY2xpZW50LWNyZWRlbnRpYWxzIiwicGVybWlzc2lvbnMiOltdfQ.VpsZK_eKlqgjlMS1UNZALh6TX69eUrGRIMAgUi0HSO6s1NIBoHQdEIuuttZt39lGPCY8yf5H_ODlWaLmYSdOfj2y0xEmD80TyaY_cbu1LQtbb9vVsoZlyFU6E-CLH38btQybTyjYngcVRz_LEfxD-ZUVAT6k78cyFlVqGbIrilR-FMKQ6U3NC6VOXdA9c0uPjLfd8e2qqjl6Zq3YnYCYjP4TI-9Q98xYJiI360PEStGSdYS2ksbCLSwxqRDPjXtcIygnNUQvOS3uI-sJwb66l7dl5uxPdAFto_WClhL9f65Ip2ZZkip6cmSPOcvuTeiJeDUGQpTRWjeLT_MQqbv3gw"
        }
Пример #17
0
    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = "capstone_test"
        self.database_path = "postgres://{}:{}@{}/{}".format(
            'postgres', '123', 'localhost:5432', self.database_name)

        self.casting_assistant = {
            'Content-Type': 'application/json',
            'Authorization': casting_assistant_token
        }
        self.casting_director = {
            'Content-Type': 'application/json',
            'Authorization': casting_director_token
        }
        self.executive_producer = {
            'Content-Type': 'application/json',
            'Authorization': executive_producer_token
        }

        setup_db(self.app, self.database_path)

        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()
Пример #18
0
    def setUp(self):
        '''Define test variables and initialize the app'''
        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = os.environ['DATABASE_TEST_NAME']
        self.database_path = os.environ[
            'DATABASE_BASE_URL'] + self.database_name
        setup_db(self.app, database_path=self.database_path)

        # JSON Data

        admin_token = os.environ['ADMIN_TOKEN']
        user_token = os.environ['USER_TOKEN']
        token_type = 'Bearer '

        self.bearer_tokens = {
            "admin": token_type + admin_token,
            "user": token_type + user_token
        }

        self.new_gym = {
            "name": "Blockhelden Bamberg",
            "address": "Memmelsdorfer Str. 211",
            "website": "https://www.blockhelden.de/",
            "city": 145,
            "status": "closed",
            "category": 1
        }

        self.edit_gym = {
            "name": "Boulderwelt Regensburg",
            "address": "Im Gewerbepark A46",
            "website": "https://www.boulderwelt-regensburg.de/",
            "city": 121,
            "status": "closed",
            "category": 1
        }

        self.new_user = {"user": "******", "last_name": "Walker"}

        self.new_user2 = {
            "user": "******",
            "last_name": "Waaaaaaaaaadfglksglkadfglkadlfkgkdfgkasdglker"
        }

        self.add_favs = {"user_id": 2, "gym_id": 6}

        self.add_wrong_favs = {"user_id": 2, "gym_id": 600}

        self.rem_favs = {"user_id": 2, "gym_id": 16}

        self.rem_error_favs = {"user_id": 2, "gym_id": 160}

        # Binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()
Пример #19
0
    def setUp(self):
        self.app = create_app()
        setup_db(self.app)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
    def setUp(self):
        """ Define the testing variables and initialize """
        self.app = create_app()
        self.app.testing = True
        self.client = self.app.test_client

        self.database_name = "casting_works_test"
        self.database_path = "postgres://{}/{}".format('localhost:5432',
                                                       self.database_name)
        setup_db(self.app, self.database_path)

        # Set Headers for Producer
        # Permissions = [[get:movies, post:movies, edit:movies, delete:movies]
        self.producer_header = {
            'Authorization':
            'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlluQnRJTEpPUC03ZjBCUEVIelU0ZiJ9.eyJpc3MiOiJodHRwczovL2Nhc3Rpbmd3b3Jrc2ZzbmQudXMuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDVmNWRhOTM2YThjYWM2MDA2ZmJiYmFhMCIsImF1ZCI6WyJhY3Rpb25zIiwiaHR0cHM6Ly9jYXN0aW5nd29ya3Nmc25kLnVzLmF1dGgwLmNvbS91c2VyaW5mbyJdLCJpYXQiOjE2MDE3MDI1NTgsImV4cCI6MTYwMTc4ODk1OCwiYXpwIjoiSEhYcEtmVWFCOHhyMUVWRjBmZkM2ZWc0dFVhcTYwZE8iLCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIiwicGVybWlzc2lvbnMiOlsiZGVsZXRlOmFjdG9ycyIsImRlbGV0ZTptb3ZpZXMiLCJlZGl0OmFjdG9ycyIsImVkaXQ6bW92aWVzIiwiZ2V0OmFjdG9ycyIsImdldDptb3ZpZXMiLCJwb3N0OmFjdG9ycyIsInBvc3Q6bW92aWVzIl19.D8VLhT2IcBjXnyLtvBfwN8sKncGMR1ZwinVlXzpe-I0gyu_lBNMmyGKxeYW6KgW5TmtepbLEyvB5TK1eMyXjUJcYqg5am9KJPPRB7rorvO-fRUKlCWz_kxJUSiUNsmthsdkLaHpcpOGJu108Xi3HXE_IMz0KzGz0ZqOfOf5NciGeWhDgbyVMGhp9lN1vWZgdM3NePZE3yqEAH7TMJM6HzLMUSmQnx9gcqktlaycGabpw9JCeTi_Wym-3OF8bepOrt5UXgDv-3UdJ_B4o7-vIJeSXUHZkf4Y64v1m7npY16b0zPP4iZSyUctsrFPpcbtz2SJVN51WSt0sxl1kdmk2AA',
            'Content-Type': 'application/json'
        }

        # Set Headers for Director
        # Permissions = [get:movies, edit:movies]
        self.director_header = {
            'Authorization':
            'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlluQnRJTEpPUC03ZjBCUEVIelU0ZiJ9.eyJpc3MiOiJodHRwczovL2Nhc3Rpbmd3b3Jrc2ZzbmQudXMuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDVmNWRhNTFhMWQ4MGIxMDA3OGU1ZTZhYiIsImF1ZCI6WyJhY3Rpb25zIiwiaHR0cHM6Ly9jYXN0aW5nd29ya3Nmc25kLnVzLmF1dGgwLmNvbS91c2VyaW5mbyJdLCJpYXQiOjE2MDE3NDgzMDIsImV4cCI6MTYwMTgzNDcwMiwiYXpwIjoiSEhYcEtmVWFCOHhyMUVWRjBmZkM2ZWc0dFVhcTYwZE8iLCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIiwicGVybWlzc2lvbnMiOlsiZGVsZXRlOmFjdG9ycyIsImVkaXQ6YWN0b3JzIiwiZWRpdDptb3ZpZXMiLCJnZXQ6YWN0b3JzIiwiZ2V0Om1vdmllcyIsInBvc3Q6YWN0b3JzIl19.Ayy_G9k7cfg4xinPmrcOw5l5IPFSpfG1l5SlW0JCK4G-2wR-0Sf1K-zf06ijiYyV_48RuoBXXdlve_3H-WMb9ALlSn5AD1VUaIa6cQs8qAlPSBNqTzi0X1lJDLm4rpFI8mkrts1v-FuqMIxLr4Y-2NwNlQItgQ714LN6Zs6qVgQgJ9gOQkbrBYH09xwHdcD0em_WZYFxHi5iIupA187JFZIwtwrUSU-x080BCGezFqA_PHwj1kVSRTDfoK5CaQOyqySNLEMVuikDEbkd5jDF8OrUg4imQIYWmCeomXKjjxVnB-qIj8hBBjCg5_OtCFEpJQTT3a9TtKn0n7UsoJ-3DQ',
            'Content-Type': 'application/json'
        }

        # Set Headers for Assistant
        # Permission = [get:movies]
        self.assistant_header = {
            'Authorization':
            'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlluQnRJTEpPUC03ZjBCUEVIelU0ZiJ9.eyJpc3MiOiJodHRwczovL2Nhc3Rpbmd3b3Jrc2ZzbmQudXMuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDVmNTcxNzVlMjA3NmE3MDA2NzhmY2VmMSIsImF1ZCI6WyJhY3Rpb25zIiwiaHR0cHM6Ly9jYXN0aW5nd29ya3Nmc25kLnVzLmF1dGgwLmNvbS91c2VyaW5mbyJdLCJpYXQiOjE2MDE3NDc1MDMsImV4cCI6MTYwMTgzMzkwMywiYXpwIjoiSEhYcEtmVWFCOHhyMUVWRjBmZkM2ZWc0dFVhcTYwZE8iLCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIiwicGVybWlzc2lvbnMiOlsiZ2V0OmFjdG9ycyIsImdldDptb3ZpZXMiXX0.AYUBIq_SOd-vKEwHZY_l1Pe0rChVwGbCPDg6g2LfinaZHSHr87r0RPqOx7bE0qzUkipmqvNLfeTLXbQ3SdcclKxmlmD6inat7m5uMZPB_l2MPxbf5lgmCXElNlmBfW7KC_irlAFZz9dvxfb3jXCav_5aXuv5svCzPbspLwj3qBcvxNbNMQB9ZPNly1FH9tUnesUD6N36LsmXVKG7GY-IEc3WivLTcjARhq3hBRVSlXDxq3pMjH2Pdo6Yb3RFfWgT176hwFcwNUP4JBfIbJc5cWGXmJ9ViGNu1AZ2MG6nvEwdaPd2xXDunfygzp6JKwDhFTN1s4kPDzlCfU6Qll4NOQ',
            'Content-Type': 'application/json'
        }
        # Set unauthorized token
        self.headers_unauth = {
            'Authorization': 'Bearer token',
            'Content-Type': 'application/json'
        }

        # New movie object success
        self.new_movie = {
            'title': 'Spider Man 11',
            'release_date': '2021-09-30'
        }
        # New movie object failure because of an empty field
        self.new_movie_fail = {'title': '', 'relase_date': '2020-09-30'}

        with self.app.app_context():
            self.db = SQLAlchemy(self.app)
            self.db.init_app(self.app)
            # Create tables
            self.db.create_all()
            # Get the first actor in the list to test editing
            self.movie_id = Movie.query.all()[0].short()['id']
            # Get the last actor in the list to test deleting
            self.delete_movie_id = Movie.query.all().pop().short()['id']
Пример #21
0
    def setUp(self):
        self.app = app
        self.client = app.test_client

        setup_db(app, database_path, True)

        self.new_movie = {"id": "12dsa3", "title": "test"}

        movie = Movies(id=self.new_movie['id'], title=self.new_movie['title'])
        movie.insert()
Пример #22
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client
        setup_db(self.app)

        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()
Пример #23
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = app.app
        self.client = self.app.test_client
        self.database_path = 'sqlite:///test_db_customer.db'
        setup_db(self.app, self.database_path, True)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()
Пример #24
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client
        setup_db(self.app)

        self.new_movie = {'title': '1919', 'date': 1582988568437}

        self.new_actor = {'name': 'lj', 'age': 24, 'gender': 1}

        self.ExecutiveProducer = 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlEwVTBOVVEzTlRjM1FrSkROVVZDUmpKQk1VSkNNekkyT0RReFFqa3dPVFJDT1RVME1UbEVSUSJ9.eyJpc3MiOiJodHRwczovL2Rldi1seGYuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDVlMTA3OGUwYjk3ZTI2MGU5OTlmY2JhNSIsImF1ZCI6Im1vdmllIiwiaWF0IjoxNTgzMDUzOTM2LCJleHAiOjE1ODMxNDAzMzYsImF6cCI6Ikhzb05CeDR0a0kycjBDOEk2QmVyRXg3UXY1eWJOQzdvIiwic2NvcGUiOiIiLCJwZXJtaXNzaW9ucyI6WyJkZWxldGU6YWN0b3IiLCJkZWxldGU6bW92aWUiLCJwb3N0OmFjdG9yIiwicG9zdDptb3ZpZSIsInB1dDphY3RvciIsInB1dDptb3ZpZSJdfQ.gbkksdS_zdwQKAKnDOKyHoYi4l7ozvcCHx5C_u9Cj9C6bw6nDLx0S1g984MIzWTASjyrEyzAlX5uO2_g74TBS-IF3RO1aXBHQxIFtFzetF04qM59copyOLqQGnKmKGZAlZaYDEjbgbIAnSSpMG9MClcKzOWHFD5sQMNin1L4kimM5U2ub2-uOP1t2OTVEfXMrRLCvnOnQrbu79c4KfcDt112D93BRv8b3kXvpgjeICAdPQmvic5TdoQthY8sFQMpbQSRX8JScbUvimIN_-SH0sekJ40zfKr3oYpmW8QXi5N5o0O_CXFZk7slN_zpYw4EqBSivrvVRIxXwK0Y-igzqw'
        self.CastingDirector = 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlEwVTBOVVEzTlRjM1FrSkROVVZDUmpKQk1VSkNNekkyT0RReFFqa3dPVFJDT1RVME1UbEVSUSJ9'
Пример #25
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client
        self.headers = {'Content-Type': 'application/json',
                        'Authorization': f'Bearer {ASSISTANT}'}
        setup_db(self.app)

        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()
Пример #26
0
    def setUp(self):
        self.token_assistant = os.environ['assistant_token']
        self.token_director = os.environ['director_token']
        self.token_producer = os.environ['producer_token']
        self.app = create_app()
        self.client = self.app.test_client
        self.database_path = "postgresql://agency@localhost:5432/agency_test"
        setup_db(self.app, self.database_path)

        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()
Пример #27
0
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app()
        self.client = self.app.test_client

        setup_db(self.app)

        # binds the app to the current context
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            # create all tables
            self.db.create_all()
        db_drop_and_create_all()
Пример #28
0
    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client

        database_path = os.environ['TEST_DATABASE_URL']
        setup_db(self.app, database_path)

        self.casting_assistant = os.environ['CASTING_ASSISTANT']
        self.casting_director = os.environ['CASTING_DIRECTOR']
        self.executive_producer = os.environ['EXECUTIVE_PRODUCER']

        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()
Пример #29
0
    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client
        database_name = "casting_agency"
        self.database_path = "postgres://*****:*****@{}/{}".format(
            'localhost:5432', database_name)
        setup_db(self.app, self.database_path)

        self.new_actor = {"name": "Test acotor", "age": 22, "gender": "Male"}
        self.new_movie = {"title": "Test movie"}
        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.drop_all()
            self.db.create_all()
Пример #30
0
    def setUp(self):
        self.Casting_Assistant = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImdKUkJUa1YzdXhaaDQxdWR1cFFWLSJ9.eyJpc3MiOiJodHRwczovL2licmFoaW1hbHNhaWYudXMuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDVmMmM0OTY3NWM4NDhmMDAzN2M0OGM0MiIsImF1ZCI6IkNhc3RpbmcgQWdlbmN5IiwiaWF0IjoxNTk2OTQ1NjkxLCJleHAiOjE1OTcwMzIwOTEsImF6cCI6IlNPQzZZdFR5aGM0aTdmS3o2OHdqNjQ3MXExWjlCQTdvIiwic2NvcGUiOiIiLCJwZXJtaXNzaW9ucyI6WyJnZXQ6YWN0b3JzIiwiZ2V0Om1vdmllcyJdfQ.kqrzkHpo9FHS_5AeqiYR_pelao8w8dEa1EGT4Qb0S1c9Q1320XEHXNo0vZPoDTP4zinBsfpktsW4jyUh466r53lGL_X8NTZk0szOJXjs0ifJO3MIFyOZ8Jc6J6VoCccYjI9QBTAgO2L7QpcmC0tuwM7db2xmk-lT5y7UjYMBae-URPoaZdEFA0wQ1hinvCi6KL-y-ct6iV5YAo-LD42t5kcfbUaRbshQakrVPvIkS_wNJoD622EM4_ZmXS-sakT6sm8imlO6PcQKTKg1PthUvHE7xL2jTZRcpd_RKgBSYnGzgez4ZdrAaZ9Tok4mySGf6RqFXlQu9180I6LjRy2eKA'
        self.Casting_Director = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImdKUkJUa1YzdXhaaDQxdWR1cFFWLSJ9.eyJpc3MiOiJodHRwczovL2licmFoaW1hbHNhaWYudXMuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDVmMmM0OTk2MzJjZWEzMDIyMTE0NzlhMCIsImF1ZCI6IkNhc3RpbmcgQWdlbmN5IiwiaWF0IjoxNTk2OTQ1Nzc4LCJleHAiOjE1OTcwMzIxNzgsImF6cCI6IlNPQzZZdFR5aGM0aTdmS3o2OHdqNjQ3MXExWjlCQTdvIiwic2NvcGUiOiIiLCJwZXJtaXNzaW9ucyI6WyJkZWxldGU6YWN0b3IiLCJnZXQ6YWN0b3JzIiwiZ2V0Om1vdmllcyIsInBhdGNoOmFjdG9yIiwicGF0Y2g6bW92aWUiLCJwb3N0OmFjdG9yIl19.r7SqGnkMa1Srf5uS7BZr9pvwUq0lIYqEbOesGY16-GH-AZhCuZB8uWpez0xb9LGkOMEaxe0qDiOWq5oKsribkYiB7W7Nl6mCzXy0HNVfDl3rTqem069F_X4VZQpD114BAz2vqExVHU5h3CzGdW0_DghS3_PBvlNCSIkbJx26ojLkXNlIp9VoxxzFr-XTo4j7iwUSvRzQwT8fi7rfiymANCn_eVWcRnJ5gm1fYocPpWYfLHVrBqXNqU1hpN_cuG24LVsv051PlGyUCupEvP-bfqSVeLjUoSPztJSYCEfskaJcBatv13MLdtrVT2gGRbn4E8JO5wM9-NA0hLB17bg6Xg'
        self.Executive_Producer = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImdKUkJUa1YzdXhaaDQxdWR1cFFWLSJ9.eyJpc3MiOiJodHRwczovL2licmFoaW1hbHNhaWYudXMuYXV0aDAuY29tLyIsInN1YiI6Imdvb2dsZS1vYXV0aDJ8MTEyNTIwOTE2ODg0NTY2NjE1NjgxIiwiYXVkIjpbIkNhc3RpbmcgQWdlbmN5IiwiaHR0cHM6Ly9pYnJhaGltYWxzYWlmLnVzLmF1dGgwLmNvbS91c2VyaW5mbyJdLCJpYXQiOjE1OTY5NDQ3MTYsImV4cCI6MTU5NzAzMTExNiwiYXpwIjoiU09DNll0VHloYzRpN2ZLejY4d2o2NDcxcTFaOUJBN28iLCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIiwicGVybWlzc2lvbnMiOlsiZGVsZXRlOmFjdG9yIiwiZGVsZXRlOm1vdmllIiwiZ2V0OmFjdG9ycyIsImdldDptb3ZpZXMiLCJwYXRjaDphY3RvciIsInBhdGNoOm1vdmllIiwicG9zdDphY3RvciIsInBvc3Q6bW92aWUiXX0.OuPWpj6cSHfrjFMUrFjKUgNuJCHxIe4KnnoZptJHjbOwjg4mAc4uPLidxU1ZZOQwSkaXNGrLwCE9THJOJF1uYwXPVum5CyVHC91Gjf6YGS9qcNYqZRj4per8HVk6-KdNtrmZfzM680fZGt-SG6AAP1M1O2fMeuDsam8UuFrx1mXrgomGavAL6ywet3oXAFGfs84YZzQgrGmIpSLsndukRV9lN488rtnZzc3EdC5EiKhJlqRisP-YSlgAFJ9dr9UxgomsNlb53RsQmbXLQUPgtb3Qw5eUEXzG99ppA6KPD86YieRhy9xzZv4IxeV8XFaPjHh9FSrYmgl3BqYVj3rKwA'
        self.app = create_app()
        self.client = self.app.test_client
        self.database_name = "casting_agency_test"
        self.database_path = "postgres://{}/{}".format(
            'postgres:7654321@localhost:5432', self.database_name)
        setup_db(self.app, self.database_path)

        with self.app.app_context():
            self.db = SQLAlchemy()
            self.db.init_app(self.app)
            self.db.create_all()