Application calculates bill based on tariff and received JSON data payload,
containing electricity usage - stored in data
folder: readings.json
.
You can assume:
- All times are UTC.
- We're only dealing with £ denominated billing.
- You only need to handle electricity and gas billing.
- Energy is consumed linearly.
- The billing date is the last day of the month.
- Readings are always taken at midnight.
- There is only one meter reading per billing period.
- The JSON file structure will remain the same in any follow on exercise.
Python3.8 installation instructions: https://docs.python.org/3/using/index.html
Ensure Python3.8
is available on the system and that you are in the directory
of the project, where Pipfile
is.
sudo pip install pipenv
pipenv install
For development use:
pipenv install --dev
Default
pipenv run python main.py
Application is able to accept arguments:
--member_id
--account_id
--bill_date
--energy_source
E.g.:
pipenv run python main.py \
--member_id member-123 \
--account_id account-abc \
--bill_date 2020-08-21 \
--energy_source electricity
pipenv run pytest
Examples of running specific tests:
pipenv run pytest tests/test_bill_member.py
pipenv run pytest tests/test_bill_member.py::TestBillMember::test_calculate_bill
Project is able to use Continuous Integration via CircleCI.
Please check configuration in .circleci/config.yml
.
- A small program which, given a set of meter readings, computes a member’s monthly energy bill.
- Tests.