For this assignment, you are going to pretend that you are writing a phone book application that stores names and phone numbers.
In order to do this, you are going to create a Phonebook class that contains the appropriate program logic to store a list of dictionaries where each dictionary contains name, phone number, and what type of phone number is being stored. Your class must include validation to ensure the following:
The rest of your implementation details are up to your discretion, applying the things you have learned about Python so far. Please note, however, that you must organize your class into a module and produce documentation (using Pydoc) for your work using the principles discussed earlier in the class. Any applicable exception handling in your code must be done according to the principles previously discussed.
Problem 1:
Write a function that accepts two parameters: course ID (e.g. IT 412) and the semester the course is to be taken in (e.g. Fall 2050). The function should return a dictionary of the form {course: < provided course ID>, semester: < provided semester>}. Thus, for a course ID of IT 412 and a semester of Fall 2050, the return should be:
{course: "IT 412", semester: "Fall 2050"}
Store the function in its own file. Next, create another file that you will use to test your new function. Write a test case class and create a method on it to ensure that the function returns data in the correct format. Make sure that when you write your class that you run it and your test passes.
Problem 2:
Write a class called InventoryItem. The constructor for the class should take in a product ID, a product name, and current quantity available. Each of these values should be stored as an attribute on the class.
Write a method called "buy_item" that takes the current quantity available property and reduces it by one by default. Code your method so that this default can be overridden.
Now, write a test case class for your InventoryItem class. Write two test methods, one to test the default behavior and one to test what happens when the default behavior is overridden. In your test class, leverage the setUp() method technique described in the textbook so you only have to instantiate your InventoryItem class once. Lastly, run your test case class and ensure that both tests pass.