Skip to content

Latest commit

 

History

History
98 lines (62 loc) · 2.11 KB

README.md

File metadata and controls

98 lines (62 loc) · 2.11 KB

This is a Python implementation of the Secmatic Order API project

The implementation is based on Python Flask

The open api contract for the services is defined in the Specmatic Central Contract Repository

Dev Setup

  • Install Python 3.12 ( use homebrew if you are on mac os)

  • Install JRE 17 or later

  • Clone the git repository

  • Virtual Environment Setup

  • Create a "virtual environment" named '.venv' by running:

    • python -m venv .venv
  • This will create a virtual environment using the default python installation, If you wish to provide a specific python installation, run:

    • py -X.Y -m venv .venv

      where X and Y are the major and minor version numbers of the python installation to use.

  • To activate your virtual environment, execute this from a terminal window in your root folder:

    • on MacOS and Linux:

      source .venv/bin/activate
    • on Windows:

      on CMD

      .venv\Scripts\activate.bat

      on PowerShell ( might have to change ExecutionPolicy )

      .\.venv\Scripts\Activate.ps1
  • Install project requirements

    From a terminal window in your root folder, run:

    pip install -r requirements.txt

Start the Flask app

  • From a terminal window in your root folder, run:

    • flask run
  • This should start the flask dev server on http://127.0.0.1:5000/

  • To check, run this route from browser:

  • You should see a response like this:

    {
    "id": 10,
    "inventory": 10,
    "name": "XYZ Phone",
    "type": "gadget"
    }

Validate contract using Specmatic

  • From a terminal window in your root folder, run:

    • pytest test -v -s
  • This should print the following output:

    Tests run: 19, Successes: 19, Failures: 0, Errors: 0