/discountCalculator

A tool that calculates the applicable discount given a list of discount bundle, a list of product and the products in the cart

Primary LanguagePython

Mirta Backend Challange - Discount Calculator

Tool that calculates the applicable discount given a list of discount bundle, a list of product and the products in the cart

Requirements

  • Python ^3.7
  • Poetry
  • Click

Installation

First of all if you don't have done yet install poetry.

pip install --user poetry

Clone the repo

git clone git@github.com:debiff/discountCalculator.git

Use Poetry to install all the dependencies of the project in a fresh virtual environment.

cd discountCalculator
poetry install

Activate the virtualenv and install the package:

poetry shell
pip install --editable .

Usage

To compute the discount run

discount_calculator --cart ABC

Options:

  • --cart(required): The products in the cart comma separated.
  • --bundle(optional): Location of JSON file containing the bundles
  • --products(optional): Location of JSON file containing the products

Test

To run the test suite execute from root

python -m unittest discover tests/