Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using python, can someone help me with this thanks the bb.py This assignment is intended to give you practice with mock objects. You're going to

Using python, can someone help me with this thanks image text in transcribed the bb.py image text in transcribed

This assignment is intended to give you practice with mock objects. You're going to write test cases for code that is supposed to operate on files packaged together. The files will be stored in compressed form, inside a zipfile which can be extracted by Python's zipfile module. If you want some hypothetical motivation for doing so, let's say that the files are not available yet, and extracting compressed files takes time and space as well as possibly creating a mess and even security issues (https:/docs.python.oribraryzipfile.html for details) so you are going to mock various parts of this problem so you can do some carly testing.] 1. You are given some existing code in "bb.py". The runTest method is deliberately undefined. Do not edit "bb.py" 2. You need to write hw3 test.py that will import the modules unittest, unittest mock, zipfile and bb and or parts of these modules 3. You will be mocking the following: o The runTestO method o The zipfile passed into the constructor for BBSubmission o This zipfile's namelist) function - you will decide what the list of filenames (strings) it should return should bc Onc approach is to o import bb and to replace ab.DBSubmission.runTest and then crcate mock objects for the zipfile object and then that mock objcct's nanelist field. 4. The test cases you need to write in "hw3_test py" are as follows: o Case where findFile is called and the file is found. You can use regular assertions here as long as you mock the namelist function correctly o Case where findFile is called and the file is not found. o Case where testSubmission is called and everything is ok all required files are found in the zipfile, so the code should reach the call to runTest. Checking if this case is ok means: 1. Checking if the zipfile object's extract) function was called with each of the file names (the test file and all of the src files there should be at least one sre file). Note that you will want to use assert any_call because assert called with only checks the most recent call 2. Checking if runTest has been called with the test ilename o Case where tesSubissionis called and one of the iles was nol found. You need to check 1. That a FileNotFoundError was raised 2. That runTest was not called Grading: (you only need lo submit hw3 lest py) 20% for mocking the required objects correctly 20% for the findFile cases 40% for the testSnbmission cases Style: 1096 proper comments for the new code you write, explaining what the mocking is supposed to accomplish Activate Windows

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

Students also viewed these Databases questions