This codebase is loosely based on the vending machine kata: accept coins as input and dispense products.
We've got a couple problems, though:
- We're missing some test coverage around a couple key methods
- We need to wire up some code for LEDs, but don't have access to the physical hardware yet.
- Install dependencies:
~$ pip3 install -r requirements.txt
- Run tests:
~$ nosetests
This legacy codebase has a few gaps in its test coverage, and we'd really like to make sure a few key scenarios are well-tested before the next big release.
You can view test coverage by running:
$ nosetests
...
$ open cover/index.html
- Write a test for
can_purchase(selected_product='orange')
when fewer than 65 cents have been inserted - Write a test for
can_purchase(selected_product='orange')
when exactly 65 cents have been inserted - Write a test for
can_purchase(selected_product='orange')
when more than 65 cents have been inserted
Vending machines are being fooled with non-coin items (washers, cardboard, etc). Write tests to validate that invalid coins are not accepted, and implement code to make your tests pass.
- Test that invalid coins are rejected
- Test that valid coins are still accepted
For purposes of testing it is often easier to substitute your own list of valid coins for the built in list.
The UX department has determined that the machine should blink a green LED when vending a fruit, to signify health and wellness.
- Write a test that verifies the green light blinks when successfully purchasing a fruit.
- Write a test that verifies the green light does not blink when can_purchase is false.
- Test it out with the real vending machine hardware!
- Run
./deploy.sh
from the shell - Remember or write down the file name and the name of the remote folder that the script told you was transferred.
- Walk to the real hardware (also called the target) and issue the following commands at the console:
cd {REMOTE-FOLDER}
tar xzf {FILE-NAME}.tgz
./vending_panel.py
There's plenty of refactoring work that can be done. And we've also heard the hardware team have installed a second LED.RED_LIGHT
which might flash in different situations.