Question
Problem Specification Given an accounting routine used in a bookshop. It works on a list with sublists (list of lists), which look like this: orders=
Problem Specification
Given an accounting routine used in a bookshop. It works on a list with sublists (list of lists), which look like this:
orders= [bookshop order1, [book1 order number, quantity, price per item], [book2 order number, quantity, price per item], ..[..,..,]], .[bookshop ordern, [,..,], [,,,..]]
orders = [ [1, ("5464", 4, 9.99), ("8274",18,12.99), ("9744", 9, 44.95)],
[2, ("5464", 9, 9.99), ("9744", 9, 44.95)],
[3, ("5464", 9, 9.99), ("88112", 11, 24.99)],
[4, ("8732", 7, 11.99), ("7733", 11,18.99), ("88112", 5, 39.95)] ]
In this assignment, you will implement two classes: Bookshop class contains all the necessary users defined methods for orders list operations (using lambda, map, filter, and reduce), and TestBookshop class, that inherits from unittest.TestCase, includes all the necessary unit tests to test all the defined methods in Bookshop class. All the test cases must be passed or ok.
- Write a method, which returns the same given list, but the tuples have 2-items only. Each tuple consists of the order number and the product of the price per items and the quantity. The product should be increased by $10 if the value of the order is less than $100.
Implement a unit test test1(), using assertEqual() to check if (actual value == expected value).
Print out the actual value and the expected value in test1.
- Write a method, which filters out the minimum price of product (price per item *quantity) per bookshop order. It returns a list with 4-tuples. Each tuple has 2 items (bookshop order number, book order number).
Implement a unit test test2(), using assertEqual() to check if (actual value == expected value).
Print out the actual value and the expected value in test2.
- Write a method, which filters out the maximum price of product (price per item* quantity) per bookshop order. It returns a list with 4-tuples. Each tuple has 2 items (bookshop order number, book order number).
Implement a unit test test3(), using assertNotEqual() to check if (actual value != wrong expected value).
Print out the actual value and the expected value in test3.
- Write a method, which returns a list with tuples. Each tuple has two items: (bookshop order number, total amount of order).
Implement a unit test test4(), using assertEqual() to check if (actual value == expected value).
Print out the actual value and the expected value in test4.
- Write a method, which returns a list with two items [book order number, total amount of the product in all orders]. This method returns the book order number that has the maximum total amount of product in all orders.
Implement a unit test test5(), using assertIn() to check if (a book order number in the returned list).
Print out the book order number and the returned list in test5.
- Write a method, which returns a list with two items [book order number, total number of its quantity in all orders]. This method returns the book order number that has the maximum total number of quantity in all orders
Implement a unit test test6(), using assertEqual() to check if (actual value == expected value).
Print out the actual value and the expected value in test6.
- Write a method, which returns an ordered list based on (bookshop order number ) per maximum total quantity. [(max bookshop order number, total quantity), ..(min bookshop order number, total quantity)]
Implement a unit test test7(), using assertEqual() to check if (actual value == expected value).
Print out the actual value and the expected value in test7.
- Write a method, which returns a total quantity of all books that have been ordered. Implement a unit test test8(), using assertEqual() to check if (actual value == expected value).
Print out the actual value and the expected value in test8.
- Write a method, which returns a list with two items [the most ordered (book order number), and the least ordered (book order number]. To figure out that, you need to count the occurrence of book order number in all orders.
Implement a unit test test9(), using assertEqual() to check if (actual value == expected value).
Print out the actual value and the expected value in test9.
- Write a method, which returns a list with 4 items. Each item represents the length of the sublists from index 0 to index 3.
Implement a unit test test10(), using assertEqual() to check if (actual value == expected value).
Print out the actual value and the expected value in test10.
Example Output:
METHOD1:
ACTUAL:
[1, ('5464', 49.96), ('8274', 233.82), ('9744', 404.55)]
[2, ('5464', 99.91), ('9744', 404.55)]
[3, ('5464', 99.91), ('88112', 274.89)]
[4, ('8732', 93.93), ('7733', 208.89), ('88112', 199.75)]
EXPECTED:
[1, ('5464', 49.96), ('8274', 233.82), ('9744', 404.55)]
[2, ('5464', 99.91), ('9744', 404.55)]
[3, ('5464', 99.91), ('88112', 274.89)]
[4, ('8732', 93.93), ('7733', 208.89), ('88112', 199.75)]
METHOD2:
ACTUAL:
(1, '5464')
(2, '5464')
(3, '5464')
(4, '8732')
EXPECTED:
(1, '5464')
(2, '5464')
(3, '5464')
(4, '8732')
METHOD3:
ACTUAL:
(1, '9744')
(2, '9744')
(3, '88112')
(4, '7733')
NOT EXPECTED:
(1, '5464')
(2, '5464')
(3, '5464')
(4, '8732')
METHOD4:
ACTUAL:
(1, 678.33)
(2, 494.46)
(3, 364.8)
(4, 492.57)
EXPECTED:
(1, 678.33)
(2, 494.46)
(3, 364.8)
(4, 492.57)
METHOD5:
ACTUAL:
['9744', 809.1]
EXPECTED:
['9744', 809.1]
METHOD6:
ACTUAL:
['5464', 22]
EXPECTED:
['5464', 22]
METHOD7:
ACTUAL:
(1, 31)
(4, 23)
(3, 20)
(2, 18)
EXPECTED:
(1, 31)
(4, 23)
(3, 20)
(2, 18)
METHOD8:
ACTUAL:
92
EXPECTED:
92
METHOD9:
ACTUAL:
['5464', '8732']
EXPECTED:
['5464', '8732']
METHOD10:
ACTUAL:
[4, 3, 3, 4]
EXPECTED:
[4, 3, 3, 4]
..........
----------------------------------------------------------------------
Ran 10 tests in 0.001s
OK
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started