Giter Club home page Giter Club logo

iso-service's Introduction

test and lint

ISO Service

The ISO service is a simple web microservice with one POST /match_country endpoint. This endpoint takes the ISO code and list of country names (in different languages) as an input. It filters out the country names corresponding to the ISO code and returns them as an output.

The functionality uses countries data provided by mledoze in his GitHub repository. This data contains a lot of information about the different countries, including their ISO codes and translations to the different languages. The service matches the country names based on this data.

Install & Run

The service is written using Python 3.9.1 and the Flask framework. The whole functionality is dockerized.

On your local machine, you need to have installed:

Once you install the required programs, navigate yourself to the root of this repository and run:

docker-compose build

This will build the image based on the Dockerfile. To run the service:

docker-compose up

This command will build and start our service container and the Redis container. The service is available at the http://localhost:5000 URL.

Note: All required environment variables are automatically set in the docker-compose.yml file to ease the process of running the service.

Example Request and Response


  • Given valid input data

    • Request

      {
          "iso": "svk",
          "countries": [
              "Slovakia",
              "Slowakei",
              "Vatikan",
              "Slovačka",
              "Szlovákia",
              "Belgrade",
              "España",
              "Nizozemsko"
          ]
      }
    • Response

      {
          "data": {
              "iso": "SVK",
              "match_count": 4,
              "matches": [
                  "Slovakia",
                  "Slowakei",
                  "Slovačka",
                  "Szlovákia"
              ]
          }
      }
  • Given invalid input data

    • Request

      {
          "iso": "svk"
      }
    • Response

      {
          "errors": [
              "'countries' is a required property"
          ]
      }
  • Given invalid JSON

    • Request

      <>
    • Response

      {
          "errors": [
              "Payload is not a valid JSON"
          ]
      }

Documentation

The documentation of the service is written using the Open API 3.0 (3.0.3) standard. The definition can be found in the docs/iso-service-v1.0.json file. You can preview this documentation, for example, by using Swagger Editor. Simply copy the contents of the file and paste it to the editor.

Tests & Linting

  • The tests are written using the pytest library.
  • The linting is enabled by using the flake8 library.

Both tests and linting are automatically run on push and pull_request using the GitHub Actions. Navigate yourself to the Actions tab to see the results of the workflows.

Used Technologies

We already mentioned some of the technologies. Let's summarize them all in the following table:

Technology Description
Python 3.9.1 Main development language.
Flask Web framework enabling the web service functionality.
Redis Works with the Flask framework to cache the API responses.
Open API 3.0 The standard used to create the documentation of the service.
Docker Used to build an image from the service.
Docker Compose Used to run the service and Redis containers together. We also use it to set the required environment variables.
GitHub Actions CI/CD used for the linting and testing the code.

Authors

  • Tomáš Patro

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

iso-service's People

Contributors

patrotom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.