Beispiel #1
0
    def testCastingAssistantGetActors(self):
        # Ensures there is at least one actor in the database to get.
        actor = Actor('James', '21', 'Male')
        actor.add()

        response = self.client().get('/actors', headers=CAAuth)
        self.assertEqual(response.status_code, 200)
Beispiel #2
0
    def testCastingDirectorDeleteActor(self):
        # Ensures there is at least one actor in the database to delete.
        actor = Actor('JamesJ', '21', 'Male')
        actor.add()

        actorId = Actor.query.filter_by(name='JamesJ').first()

        response = self.client().delete('/actors/' + str(actorId.id),
                                        headers=CDAuth)
        self.assertEqual(response.status_code, 200)
Beispiel #3
0
 def post_actors(payload):
     name = request.get_json().get('name', 'unknown')
     age = request.get_json().get('age', 0)
     gender = request.get_json().get('gender', 'unknown')
     actor = Actor(name, age, gender)
     actor.add()
     return jsonify({
         'success': True,
         'actor': actor.format()
     })
Beispiel #4
0
    def testDeleteActorSuccess(self):
        # Ensures there is at least one actor in the database to delete.
        actor = Actor('JamesJ', '21', 'Male')
        actor.add()

        numOfActorsBefore = len(Actor.query.all())
        actorId = Actor.query.filter_by(name='JamesJ').first()

        response = self.client().delete('/actors/' + str(actorId.id),
                                        headers=self.headers)
        data = json.loads(response.data.decode())

        numOfActorsAfter = len(Actor.query.all())

        self.assertEqual(response.status_code, 200)
        self.assertEqual(numOfActorsBefore - 1, numOfActorsAfter)
Beispiel #5
0
    def testGetActorsSuccess(self):
        # Ensures there is at least one actor in the database to get.
        actor = Actor('James', '21', 'Male')
        actor.add()

        actors = Actor.query.all()
        numOfActors = len(actors)

        response = self.client().get('/actors',
                                     headers=self.headers)
        data = json.loads(response.data.decode())

        # Checks the ids in the response against the ids in the database.
        sameIds = all([data['actors'][i]['id'] ==
                       actors[i].id for i in range(0, numOfActors)])

        self.assertEqual(response.status_code, 200)
        self.assertTrue(isinstance(data['actors'], list))
        self.assertTrue(sameIds)
        self.assertEqual(len(data['actors']), numOfActors)
Beispiel #6
0
    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client
        self.database_path = os.environ['HEROKU_POSTGRESQL_MAUVE_URL']
        self.casting_assistant_token = os.environ['CASTING_ASSISTANT_TOKEN']
        self.casting_director_token = os.environ['CASTING_DIRECTOR_TOKEN']
        self.executive_producer_token = os.environ['EXECUTIVE_DIRECTOR_TOKEN']
        self.db = setup_db(self.app, database_path=self.database_path)

        self.new_movie = {"title": "new_title", "release_date": "1999/1/1"}

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

        # binds the app to the current context
        with self.app.app_context():
            self.db.init_app(self.app)
            # create all tables
            self.db.drop_all()
            self.db.create_all()
            movie = Movie("title", "1999/1/1")
            movie.add()
            actor = Actor("name", 0, "gender")
            actor.add()