Starting from:

$30

INST326-Exercise Testing Solved

 Instructions
 Write a script named bulkpricing.py. This script should contain only one function named getcost() that calculates the cost of an order of magnets using the pricing scheme in the table above. Your function should take a non-negative number of magnets (an integer) as its only argument. It should return a float indicating the cost of the order in dollars.

 If the number of magnets is less than zero, your function should return 0.

 Write an if name == 'main': statement where you call the get_cost() function using any value you would like to test. You do not have to print any output, but it might be helpful to print out the returned value after you call the function.

 Please make sure you function has a docstring that briefly states:

 What the function does?
What argument(s) it requires?
What kind of value it returns and what this value means?
What error(s) it raises and what they mean?
 Write a test script with at least four "happy path" test cases and at least four edge cases. Make it clear which test cases fall into which categories (for example, you might split them into separate functions, or you might include comments marking the start of each type of test case).

 You should create your test script in the same directory as your bulk pricing script. Have your test script import your get_cost() function. Run your test script using Pytest. If any tests fail, determine whether the failure is due to mistakes in the original script or the test script.

 Running your program
 To run your program, open a terminal and ensure you are in the directory where your script is saved. At the command prompt, type python3 (Windows users, type python instead) followed by a space and the name of your script. For example, if your script were called bulk_pricing.py you would type

More products