Skip to content

Individual Contribution Report 2 | Omer Talip Akalin

Ömer Talip Akalın edited this page May 12, 2023 · 7 revisions

Member

Name: Omer Talip Akalin

Main git issues (significant ones only)

  • We were storing passwords without hash :) #179
  • Implementing the task (with unit tests, in a single issue) #195

The name, route, description of utilized third party URIs

For this practice app, I've used the Instatus API.

Instatus a service for companies to announce the status of their systems in real time. I've utilized the API to fetch the status of incidents and to update the status of incidents based on a mock company I formed, namely Tcorp. For this specific purpose, I prepared a template incident and used it only. You can check it here.

The routes used are https://api.instatus.com/v1/{PAGE_ID}/incidents for fetching incidents and https://api.instatus.com/v2/{PAGE_ID}/incidents/{curr_inc_id}/incident-updates/{template_id} for updating incidents, where one template is for resolving an incident and the other one is for investigating an incident.

The name, route, description of the created API functions

I've configured API functions for a GET request and a POST request.

POST - change_status: This function is accessed via the route /change_status/<new_status> and is used to change the status of incident of the application, by setting <new_status> to resolved or investigating. Otherwise, it returns an error.

GET - get_current_status: This function is accessed via the route /get_current_status and is used to fetch the current status of incident / page.

To fetch the page, I also added the route of get_status_page:

get_status_page: This function is accessed via the route /status_page and is used to render the status page of our application.

Description of Unit Tests

In the unit tests, I've tried to validate my API endpoints. To do so, I used pytest and unittest libraries, which are quite handy to use.

I added tests to the endpoint with mocks to:

  • Test the status page & title
@patch("app.views.get_current_status")
def test_get_status_page(mock_get_current_status, client):
    mock_get_current_status.return_value = MagicMock(
        response=[json.dumps({"status": 200, "message": "RESOLVED"})]
    )
    response = client.get("/status_page")
    assert response.status_code == 200
    assert b"Current Status: STABLE" in response.data
  • Test invalid post request
def test_change_status_invalid(client):
    response = client.post("/change_status/invalid")
    assert response.json == {"status": 404, "message": "Page not found"}
  • Test the investigating case
@patch("app.views.get_all_incidents")
@patch("requests.post")
def test_change_status_investigating(mock_post, mock_get_all_incidents, client):
    mock_get_all_incidents.return_value = [{"id": "1", "status": "RESOLVED"}]
    mock_post.return_value.status_code = 200
    response = client.post("/change_status/investigating")
    assert response.json == {
        "status": 200,
        "message": "Status changed - investigating",
    } or response.json == {
        "message": "Status INVESTIGATING already",
        "status": 200,
    }
  • Test the resolved case
  • Test whether fetching the current status works correctly

Sample Calls

TODO

Any other significant work

I've handled many pull requests as a reviewer, and I also tried my best to solve problems regarding Git. In these pull requests, I requested many reasonable changes, which's been liked by my teammates.

Here are some of the pull requests that I reviewed:

I also proposed the idea of using Flask as it's easy to onboard. I also showed a couple of tricks for development.

I have joined the implementation & discussion phases two weeks late (due to some personal problems). But I truly believe that I contributed to the team, especially in terms of organization, effectively.

Challenges that I encountered

As a person who uses Docker daily, I never knew it was that challenging to build Postgresql to use in the container localhost. We (me and @erkamkavak) have encountered so many interesting bugs that at some point I was proposing to change it to Postgresql.

Other than that, this task made me remember how much I prefer not to write Javascript.

Clone this wiki locally