[SOLVED] INST326-Exercise-Testing-main

30.00 $

Category:

Description

Rate this product

# Background

An  online  magnet  seller  sells  a  particular  magnet  at  a  base  price  of  $0.75  but  offers  bulk  pricing
depending on the quantity of magnets ordered, as follows:

<img width=”420″ alt=”Screen Shot 2022-01-03 at 8 36 36 PM” src=”https://user-images.githubusercontent.com/90868294/147998254-cee5bdfa-69fe-4d88-969c-ff40afba4f76.png”>

# Instructions
Write a script named **bulk_pricing.py**. This script should contain only one function named **get_cost()**  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