Milestone 2: Personal Contribution Page (Ahmet Emre Şafak) - bounswe/bounswe2023group4 GitHub Wiki

Ahmet Emre Şafak

For my API, I have chosen the [OMDB API] The OMDB (Open Movie Database) API is a web service that provides a comprehensive database of movies, TV shows, and related information. It allows developers to access a vast collection of data about movies and TV series, including details such as titles, release dates, genres, ratings, cast and crew information, plot summaries, posters, and more. It can be tracked from issue #73. Moreover, I was also part of the frontend team and developed 2 different pages for Movies and Polls api. This can be tracked from issue #135

API Functions

movie_fetch

  • Name: movie_fetch
  • Route: /api/movie_fetch
  • Description: This functionality represents a Django API view that receives GET requests with parameters for movie details, makes a request to the OMDB API, saves the retrieved movie data into a database, and returns the serialized movie object as a response.

Unit Tests

Ali Nasra wrote most of this. Thank him for his help. I just reviewed most of it and created it.

2023-05-12 22_33_35-test_movie py - practice-app - Visual Studio Code

1- The code sets up a test environment by creating a test client, inserting two Movie objects into the database, and assigning all Movie objects to the variable "self.countries" for testing purposes.

2023-05-12 22_33_44-test_movie py - practice-app - Visual Studio Code

2- The code snippet tests the functionality of retrieving all movies by sending a GET request to the '/api/movie/' endpoint. It asserts that the response status code is 200, checks if the imdbID of the first movie in the response is "NT20232", and verifies that the response contains a total of two movies.

2023-05-12 22_33_55-test_movie py - practice-app - Visual Studio Code

3- This test case checks if the '/api/movie/' endpoint, when given the 'Title=Joker' parameter, returns the expected movie with the title "Joker" in the response. It verifies the response status code is 200, the title of the movie matches the expected value, and only one movie is returned in the response list.

2023-05-12 22_34_08-test_movie py - practice-app - Visual Studio Code

4- This test case checks if sending a POST request to the '/api/movie/' endpoint with movie details successfully adds a new movie to the API. It verifies that the response contains the expected title for the added movie and that the total number of movies in the database increases by one.

2023-05-12 22_34_11-test_movie py - practice-app - Visual Studio Code

5- This test case verifies that the '/api/movie_fetch/' endpoint successfully collects data from third-party APIs and adds at least three movies to the database. It checks if the total number of Movie objects in the database is greater than 3.

Sample Calls


Challenges

The biggest challenge I have met was creating the backend for movies. It took me a lot of time to grasp the Django. I was familiar with REST APIs but I did not know how to create one. Thus, I struggled to create one.