Ejemplo n.º 1
0
    def test_delete_actor(self):
        """Tests delete an actor success"""
        actor = Actor(
            name=self.actor_2['name'],
            age=self.actor_2['age'],
            gender=self.actor_2['gender'],
            image_link=self.actor_2['imageLink'],
            phone=self.actor_2['phone'],
            website=self.actor_2['website'],
        )

        actor.insert()

        actor_id = actor.id

        # try to delete the actor
        response = self.client.delete(f'/api/actors/{actor_id}',
                                      headers=self.director_header)
        data = json.loads(response.data)

        # check the status code / message
        self.assertEqual(response.status_code, 200)
        self.assertEqual(data['success'], True)

        # check if the actor id matches the deleted_id field
        self.assertEqual(data['deleted_id'], actor_id)

        # check if the actor has been deleted
        a = Actor.query.filter(Actor.id == actor_id).one_or_none()

        # see if the actor is now None after it has been deleted
        self.assertEqual(a, None)
Ejemplo n.º 2
0
 def test_delete_actor_success(self):
     actor = Actor(name="Prince", age="52", gender="male")
     actor.insert()
     res = self.client.delete('/actors/%s' % actor.id)
     data = json.loads(res.data)
     self.assertEqual(res.status_code, 200)
     self.assertTrue(data['success'])
     self.assertEqual(data['actor_id'], actor.id)
Ejemplo n.º 3
0
 def test_delete_movies_success(self):
     movie = Actor(title="LALALA", release_data="05022023", genre="malodrama")
     movie.insert()
     res = self.client.delete('/movies/%s' % movie.id)
     data = json.loads(res.data)
     self.assertEqual(res.status_code, 200)
     self.assertTrue(data['success'])
     self.assertEqual(data['movie_id'], movie.id)
Ejemplo n.º 4
0
 def test_actors_list_success(self):
     actor = Actor(name="Yara Shahidi", age="20", gender="female")
     actor.insert()
     res = self.client().get('/actors')
     data = json.loads(res.data)
     self.assertEqual(res.status_code, 200)
     self.assertTrue(data['success'])
     actors = Actor.query.all()
     self.assertEqual(len(data['actors']), len(actors))
Ejemplo n.º 5
0
def restart_db_with_test_data():
    db_drop_and_create_all()
    for actor in actors:
        actor_obj = Actor(name=actor["name"],
                          age=actor["age"],
                          gender=actor["gender"])
        actor_obj.insert()

    for movie in movies:
        movie_obj = Movie(title=movie["title"],
                          release_date=movie["release_date"])
        movie_obj.insert()
Ejemplo n.º 6
0
def create_actor(jwt):
    data = request.get_json()
    # checks for presence of content in data
    if not data:
        abort(400)

    # retrieves data from request
    name = data['name']
    age = data['age']
    gender = data['gender']
    # creates a new instance of actor passing the retrieved data
    actor = Actor(name=name, age=age, gender=gender)
    try:
        actor.insert()
    except:
        abort(422)

    return jsonify({'success': True, 'actor': actor.format()})
Ejemplo n.º 7
0
    def test_delete_actor_403(self):
        """Tests delete an actor cannot be created by an assistant"""
        actor = Actor(
            name=self.actor_2['name'],
            age=self.actor_2['age'],
            gender=self.actor_2['gender'],
            image_link=self.actor_2['imageLink'],
            phone=self.actor_2['phone'],
            website=self.actor_2['website'],
        )

        actor.insert()

        actor_id = actor.id

        # try to delete the actor
        response = self.client.delete(f'/api/actors/{actor_id}',
                                      headers=self.assistant_header)
        data = json.loads(response.data)

        # check the status code / message
        self.assertEqual(response.status_code, 403)
        self.assertEqual(data['success'], False)
Ejemplo n.º 8
0
def populate_films():
    harry_potter_and_ph_stone = Film(
        title='Harry Potter and the Philosopher\'s Stone',
        release_date=date(2001, 11, 4),
        description=
        'An orphaned boy enrolls in a school of wizardry, where he learns the truth about himself, his family and the terrible evil that haunts the magical world.',
        distributed_by='Warner Bros. Pictures',
        length=152,
        rating=7.6,
    )
    harry_potter_and_ch_s = Film(
        title='Harry Potter and Chamber of Secrets',
        release_date=date(2002, 11, 3),
        description=
        'An ancient prophecy seems to be coming true when a mysterious presence begins stalking the corridors of a school of magic and leaving its victims paralyzed.',
        distributed_by='Warner Bros. Pictures',
        length=161,
        rating=7.4,
    )
    harry_potter_and_priz_az = Film(
        title='Harry Potter and the Prizoner of Azkaban',
        release_date=date(2004, 6, 4),
        description=
        'Harry Potter, Ron and Hermione return to Hogwarts School of Witchcraft and Wizardry for their third year of study, where they delve into the mystery surrounding an escaped prisoner who poses a dangerous threat to the young wizard.',
        distributed_by='Warner Bros. Pictures',
        length=142,
        rating=7.9,
    )
    harry_potter_and_ph_goblet_fire = Film(
        title='Harry Potter and the Goblet of Fire',
        release_date=date(2005, 11, 6),
        description=
        'Harry Potter finds himself competing in a hazardous tournament between rival schools of magic, but he is distracted by recurring nightmares.',
        distributed_by='Warner Bros. Pictures',
        length=157,
        rating=7.7,
    )
    harry_potter_and_order_phoenix = Film(
        title='Harry Potter and the Order of the Phoenix',
        release_date=date(2007, 7, 19),
        description=
        'With their warning about Lord Voldemort\'s (Ralph Fiennes\') return scoffed at, Harry (Daniel Radcliffe) and Dumbledore (Sir Michael Gambon) are targeted by the Wizard authorities as an authoritarian bureaucrat slowly seizes power at Hogwarts.',
        distributed_by='Warner Bros. Pictures',
        length=138,
        rating=7.5,
    )
    harry_potter_and_half_blood_prince = Film(
        title='Harry Potter and the Half-Blood Prince',
        release_date=date(2009, 7, 16),
        description=
        'As Harry Potter (Daniel Radcliffe) begins his sixth year at Hogwarts, he discovers an old book marked as "the property of the Half-Blood Prince" and begins to learn more about Lord Voldemort\'s (Ralph Fiennes\') dark past.',
        distributed_by='Warner Bros. Pictures',
        length=153,
        rating=7.6,
    )
    harry_potter_and_deathly_hallows_1 = Film(
        title='Harry Potter and the Deathly Hallows part 1',
        release_date=date(2010, 11, 18),
        description=
        'As Harry (Daniel Radcliffe), Ron (Rupert Grint), and Hermione (Emma Watson) race against time and evil to destroy the Horcruxes, they uncover the existence of the three most powerful objects in the wizarding world: the Deathly Hallows.',
        distributed_by='Warner Bros. Pictures',
        length=146,
        rating=7.7,
    )
    harry_potter_and_deathly_hallows_2 = Film(
        title='Harry Potter and the Deathly Hallows part 2',
        release_date=date(2011, 7, 13),
        description=
        'Harry, Ron, and Hermione search for Voldemort\'s remaining Horcruxes in their effort to destroy the Dark Lord as the final battle rages on at Hogwarts.',
        distributed_by='Warner Bros. Pictures',
        length=130,
        rating=8.1,
    )

    daniel_radcliffe = Actor(name='Daniel Radcliffe',
                             birthday=date(1989, 7, 23),
                             is_active=True)
    emma_watson = Actor(name='Emma Watson',
                        birthday=date(1990, 4, 15),
                        is_active=True)
    rupert_grint = Actor(name='Rupert Grint',
                         birthday=date(1988, 9, 24),
                         is_active=True)
    richard_harris = Actor(name='Richard Harris',
                           birthday=date(1930, 10, 1),
                           is_active=False)
    michael_gambon = Actor(name='Michael Gambon',
                           birthday=date(1940, 10, 19),
                           is_active=True)
    alan_rickman = Actor(name='Alan Rickman',
                         birthday=date(1946, 2, 21),
                         is_active=False)

    db.session.add(harry_potter_and_ph_stone)
    db.session.add(harry_potter_and_ch_s)
    db.session.add(harry_potter_and_priz_az)
    db.session.add(harry_potter_and_ph_goblet_fire)
    db.session.add(harry_potter_and_order_phoenix)
    db.session.add(harry_potter_and_half_blood_prince)
    db.session.add(harry_potter_and_deathly_hallows_1)
    db.session.add(harry_potter_and_deathly_hallows_2)

    db.session.add(daniel_radcliffe)
    db.session.add(emma_watson)
    db.session.add(rupert_grint)
    db.session.add(richard_harris)
    db.session.add(michael_gambon)
    db.session.add(alan_rickman)

    db.session.commit()
    db.session.close()
Ejemplo n.º 9
0
 def test_update_actor_success(self):
     actor = Actor(name="Corona", genre="male/female/others", age="1")
Ejemplo n.º 10
0
def populate_films():
    harry_potter_and_ph_stone = Film(
        title='Harry Potter and the Philosopher\'s Stone',
        release_date=date(2001, 11, 4),
        description='An aaaaaaaa aaaaa aaaaaaaa aaaaaaa',
        distributed_by='Warner Bros. Pictures',
        length=161,
        rating=7.6,
    )
    harry_potter_and_ch_s = Film(
        title='Harry Potter and the Ch S',
        release_date=date(2002, 11, 3),
        description='An aaaaaaaa aaaaa aaaaaaaa aaaaaaa',
        distributed_by='Warner Bros. Pictures',
        length=161,
        rating=7.4,
    )
    harry_potter_and_priz_az = Film(
        title='Harry Potter and the Priz Az',
        release_date=date(2004, 6, 4),
        description='An aaaaaaaa aaaaa aaaaaaaa aaaaaaa',
        distributed_by='Warner Bros. Pictures',
        length=161,
        rating=7.9,
    )
    harry_potter_and_ph_goblet_fire = Film(
        title='Harry Potter and the Goblet Fire',
        release_date=date(2005, 11, 6),
        description='An aaaaaaaa aaaaa aaaaaaaa aaaaaaa',
        distributed_by='Warner Bros. Pictures',
        length=161,
        rating=7.6,
    )
    harry_potter_and_order_phoenix = Film(
        title='Harry Potter and the Order Phoenix',
        release_date=date(2007, 7, 19),
        description='An aaaaaaaa aaaaa aaaaaaaa aaaaaaa',
        distributed_by='Warner Bros. Pictures',
        length=161,
        rating=7.6,
    )
    harry_potter_and_half_blood_prince = Film(
        title='Harry Potter and the Half-Blood Prince',
        release_date=date(2001, 11, 4),
        description='An aaaaaaaa aaaaa aaaaaaaa aaaaaaa',
        distributed_by='Warner Bros. Pictures',
        length=161,
        rating=7.6,
    )
    harry_potter_and_deathly_hallows_1 = Film(
        title='Harry Potter and the Deathly Hallows part 1',
        release_date=date(2001, 11, 4),
        description='An aaaaaaaa aaaaa aaaaaaaa aaaaaaa',
        distributed_by='Warner Bros. Pictures',
        length=161,
        rating=7.6,
    )
    harry_potter_and_deathly_hallows_2 = Film(
        title='Harry Potter and the Deathly Hallows part 2',
        release_date=date(2001, 11, 4),
        description='An aaaaaaaa aaaaa aaaaaaaa aaaaaaa',
        distributed_by='Warner Bros. Pictures',
        length=161,
        rating=7.6,
    )

    daniel_radcliffe = Actor(name='Daniel Radcliffe', birthday=date(1989, 7, 23), is_active=True)
    emma_watson = Actor(name='Emma Watson', birthday=date(1990, 4, 15), is_active=True)
    rupert_grint = Actor(name='Rupert Grint', birthday=date(1988, 9, 24), is_active=True)
    richard_harris = Actor(name='Richard Harris', birthday=date(1939, 10, 1), is_active=True)
    michael_gambon = Actor(name='Michael Gambon', birthday=date(1940, 10, 19), is_active=True)
    alan_rickman = Actor(name='Alan Rickman', birthday=date(1946, 2, 21), is_active=True)

    db.session.add(harry_potter_and_ph_stone)
    db.session.add(harry_potter_and_ch_s)
    db.session.add(harry_potter_and_priz_az)
    db.session.add(harry_potter_and_ph_goblet_fire)
    db.session.add(harry_potter_and_order_phoenix)
    db.session.add(harry_potter_and_half_blood_prince)
    db.session.add(harry_potter_and_deathly_hallows_1)
    db.session.add(harry_potter_and_deathly_hallows_2)

    db.session.commit()
    db.session.close()