1. Project Description Project Description Due Date 11 / 09 / 21 @ 11:59pm Objectives Review working with list methods to perform common manipulations, such as searching for items, sorting a list,...

1 answer below »

1. Project Description


Project Description


Due Date

11 / 09 / 21 @ 11:59pm

Objectives



  • Review working with list methods to perform common manipulations, such as searching for items, sorting a list, inserting items and removing items.

  • Review working with additional Python functional-style programming capabilities, including lambdas and the operations filter, map and reduce.

  • Usingunittestframework


Problem Specification & Input

In this project, you will work with Python’s built-inunittestframework to perform Python unit testing,
Given an accounting routine used in a bookshop. It works on a list with sublists, which look like this:

orders = [[bookshop order1, \ (book1 order number, quantity, price per item), \ (book2 order number, quantity, price per item), \ ... ], \ ..., \ [bookshop ordern, \ (book1 order number, quantity, price per item), \ (book2 order number, quantity, price per item), \ ... ]]



>>> 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 project, you will implement two classes:Bookshopclass contains all the necessary user’s defined methods for orders list operations (using lambda, map, filter, and reduce), andTestBookshopclass, that inherits fromunittest.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 by10ifthevalueoftheorderislessthan" role="presentation" style="display: inline; line-height: normal; word-spacing: normal; overflow-wrap: normal; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; transition: none 0s ease 0s; position: relative; vertical-align: 0px;">10ifthevalueoftheorderislessthan10ifthevalueoftheorderislessthan100.
    Implement a unit testtest1(), usingassertEqual()to check if (actual value == expected value).
    Print out the actual value and the expected value intest1().

  2. 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 testtest2(), usingassertEqual()to check if (actual value == expected value).
    Print out the actual value and the expected value intest2().

  3. 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 testtest3(), usingassertNotEqual()to check if (actual value != wrong expected value).
    Print out the actual value and the expected value intest3().

  4. Write a method, which returns a list with tuples. Each tuple has two items: (bookshop order number, total amount of order).
    Implement a unit testtest4(), usingassertEqual()to check if (actual value == expected value).
    Print out the actual value and the expected value intest4().

  5. 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 testtest5(), usingassertIn()to check if (a book order number in the returned list).
    Print out the book order number and the returned list intest5().

  6. 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 testtest6(), usingassertEqual()to check if (actual value == expected value).
    Print out the actual value and the expected value intest6().

  7. 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 testtest7(), usingassertEqual()to check if (actual value == expected value).
    Print out the actual value and the expected value intest7().

  8. Write a method, which returns a total quantity of all books that have been ordered. Implement a unit testtest8(), usingassertEqual()to check if (actual value == expected value).
    Print out the actual value and the expected value intest8().

  9. 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 testtest9(), usingassertEqual()to check if (actual value == expected value).
    Print out the actual value and the expected value intest9().

  10. 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 testtest10(), usingassertEqual()to check if (actual value == expected value).
    Print out the actual value and the expected value intest10().


Additional Requirements


Coding Standards

You must adhere to all conventions applicable to writing programs. This includes the use of white spaces and indentations for readability, the use of comments to explain the meaning of various methods and attributes, and the conventions for naming classes, variables, method parameters and methods.

Assignment Submission



  • Develop and submit your project on Codio.

NOTE: The penalty for late submissions as stated in the course syllabus will be applied in grading any assignment submitted late.

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 IN: 9744 . 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

TRY IT
Answered 97 days AfterNov 06, 2021

Answer To: 1. Project Description Project Description Due Date 11 / 09 / 21 @ 11:59pm Objectives Review working...

Sathishkumar answered on Feb 12 2022
113 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here