Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given an accounting routine used in a bookshop. It works on a list with sublists (list of lists), which look like this: orders= [bookshop order

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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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]

Design Requirements

Your program should have a class Bookshop which implements the methods given below.

class Bookshop: def method1(self,orders): # receives a list of lists and returns a list with tuples of two items. def method2(self,orders):

# receives a list of lists, filtirs out the min. price and returns a list.

def method3(self,orders):

# receives a list of lists, filtirs out the max. price and returns a list. def method4(self,orders):

# receives a list of lists and returns a list of tuples.

def method5(self,orders):

# receives a list of lists and returns a list.

def method6(self,orders):

# receives a list of lists and returns a list.

def method7(self,orders):

# receives a list of lists and returns an ordered list.

def method8(self,orders):

# receives a list of lists and returns an integer.

def method9(self,orders):

# receives a list of lists and returns a list.

def method10(self,orders):

# receives a list of lists and returns a list.

You must also include a TestBookshop class in your project with the following methods.

class TestBookshop(unittest.Testcase):

def setup(self): # Creates an instance for Bookshop class. # Initializes the list of lists = order def test_method1(self):

# Initializes the expected value.

# Calls method1 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

def test_method2(self):

# Initializes the expected value.

# Calls method2 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

def test_method3(self):

# Initializes the expected value.

# Calls method3 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

def test_method4(self):

# Initializes the expected value.

# Calls method4 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

def test_method5(self):

# Initializes the expected value.

# Calls method5 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

def test_method6(self):

# Initializes the expected value.

# Calls method6 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

def test_method7(self):

# Initializes the expected value.

# Calls method7 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

def test_method8(self):

# Initializes the expected value.

# Calls method8 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

def test_method9(self):

# Initializes the expected value.

# Calls method9 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

def test_method10(self):

# Initializes the expected value.

# Calls method10 and tests the returned value (actual value) using assert method

# Displays the actual and expected values

Your project should also have a special attribute __name__ that is set to __main__ as follows:

If __name__ == __main__:

Unittest.main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Horngrens Financial and Managerial Accounting

Authors: Tracie L. Nobles, Brenda L. Mattison, Ella Mae Matsumura

5th edition

9780133851281, 013385129x, 9780134077321, 133866297, 133851281, 9780133851298, 134077326, 978-0133866292

Students also viewed these Accounting questions