Individual Contribution Report 2 Ali Üçer - bounswe/bounswe2023group3 GitHub Wiki

Some Issues Related to Project

issue 1

issue 2

issue 3

issue 4

External API

Rest Countries API is a web service that provides developers with various information about countries. Using this API, you can get a country's name, population, area, capital, geographic coordinates, official languages, currencies, territory and sub-region information, borders and many other information.

For example, while developing an application, you can use this API to provide your users with comprehensive information about the whole world. You can also collect data for maps, geographic statistics and similar data driven projects using this API

Documentation of My App

This Django application provides functionality to search for country information, add countries to favorites, remove countries from favorites, and list the favorite countries. Here's a breakdown of the components and their functionalities:

views.py : This file contains the view functions that handle HTTP requests and return responses.

search_country : Handles a GET request to search for country information. It calls the get_country_info function from the services.py module to retrieve the country information and returns it as a JSON response.

add_to_favorites : Handles a GET request to add a country to the favorites. It creates a new FavoriteCountry object with the provided country name and returns a JSON response with a success message.

remove_from_favorites : Handles a GET request to remove a country from the favorites. It deletes the FavoriteCountry object with the provided country name and returns a JSON response with a success message.

list_favorites : Handles a GET request to list all the favorite countries. It retrieves all the FavoriteCountry objects and returns their names as a JSON response.

urls.py : This file defines the URL patterns for the application.

The empty path ('') maps to the home view.

The 'search/' path maps to the search_country view.

The 'add_to_favorites/' path maps to the add_to_favorites view.

The 'remove_from_favorites/' path maps to the remove_from_favorites view.

The 'list_favorites/' path maps to the list_favorites view.

tests.py : This file contains test cases for the views.

test_search_country_GET : Tests the search_country view by sending a GET request with a country name and asserts that the response status code is 200 and the returned data matches the expected country information.

test_add_to_favorites_POST : Tests the add_to_favorites view by sending a POST request with a country name and asserts that the response status code is 200 and a new FavoriteCountry object is created.

test_remove_from_favorites_POST : Tests the remove_from_favorites view by first adding a country to favorites, then sending a POST request to remove it, and asserts that the response status code is 200 and the FavoriteCountry object is deleted.

services.py : This file contains the get_country_info function, which makes an HTTP request to an external API (restcountries.com) to fetch country information. It parses the response JSON and returns a dictionary with useful information about the country.

models.py : This file defines the FavoriteCountry model, which represents a favorite country with a unique country name.

appear.html : This is an HTML template that renders a simple web page for interacting with the application. It includes input fields for country name, buttons to perform search, add to favorites, remove from favorites, and list favorites. The results are displayed in the designated

elements.

URL of Deployed Application

URL of the Deployed Application: Deployed Application

URL of the Swagger

URL of the Swagger: Swagger

Unit Tests

I used 3 unit tests. First one tests search, second one tests add to favorites, third one tests remove from favorites of the program. ` '

def test_search_country_GET(self):
    response = self.client.get(self.search_url, {'country_name': 'Turkey'})

    self.assertEquals(response.status_code, 200)
    self.assertJSONEqual(
        str(response.content, encoding='utf8'),
        get_country_info('Turkey')
    )

def test_add_to_favorites_POST(self):
    response = self.client.post(self.add_to_favorites_url, {'country_name': 'Turkey'})

    self.assertEquals(response.status_code, 200)
    self.assertEquals(FavoriteCountry.objects.count(), 1)

def test_remove_from_favorites_POST(self):
    self.client.post(self.add_to_favorites_url, {'country_name': 'Turkey'})
    response = self.client.post(self.remove_from_favorites_url, {'country_name': 'Turkey'})

    self.assertEquals(response.status_code, 200)
    self.assertEquals(FavoriteCountry.objects.count(), 0)`

Technologies I used

The Django Rest Framework has been instrumental in providing me the ability to perform data exchanges in JSON format, a critical aspect of modern web applications. Coupled with HTML, it has enabled me to create rich and interactive web pages.

SQLite, as a disk-based, lightweight database system, has offered me efficiency and simplicity without the need for a dedicated server process. Its integration with Django has facilitated seamless database operations, streamlining my development process.

Swagger has served as an intuitive documentation tool, aiding my understanding and effective use of APIs. It has enabled both myself and potential users to utilize my APIs efficiently, providing a seamless user experience.

Docker has ensured the portability of my application by packaging all dependencies and environmental variables into a single container. It has allowed easy deployment across different servers or cloud environments and made my testing processes more efficient by quickly creating and demolishing test environments.

Amazon Web Services (AWS) has provided reliable cloud computing services, enabling the swift and reliable deployment of my application. It has facilitated the creation and deployment of servers to run Docker images.

Lessons I learned

I learned how to use github and git better, although I made a mistake at first and committed to main, then I mastered concepts such as review, branch, pull request. I learned the technologies I mentioned above. I realized the benefits of asking my teammates for help and learning together.

⚠️ **GitHub.com Fallback** ⚠️