Write test cases for code

Assignment Help Python Programming
Reference no: EM131849607

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.

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:

  • The runTest() method
  • The zipfile passed into the constructor for BBSubmission
  • This zipfile's namelist() function - you will decide what the list of filenames (strings) it should return should be

One approach is to

  • import bb

and to replace bb.BBSubmission.runTest and then create mock objects for the zipfile object and then that mock object's namelist field.

4. The test cases you need to write in "hw3_test.py" are as follows:

  • 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
  • Case where findFile is called and the file is not found.
  • 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 src 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 filename
  • Case where testSubmission() is called and one of the files was not found. You need to check
  1. That a FileNotFoundError was raised
  2. That runTest was not called

Attachment:- bb.rar

Reference no: EM131849607

Questions Cloud

What exactly is a welfare program : What exactly is a welfare program? Please explain and give specifics
Has a decision been made in your case : Has a decision been made in your case? If yes, what was that decision? How many Justices voted for/against the decision?
Preferences and policy outcomes in europe : Why is there a gap between voters preferences and policy outcomes in Europe?
Is political neutrality indispensable for an efficient : Is political neutrality indispensable for an efficient bureaucracy? Why or why not? Use the civil-service system in a specific country
Write test cases for code : Write file that will import the modules unittest, unittest.mock, zipfile and bb and/or parts of these modules 3. You will be mocking the following:
The difference between traditional tax and audit services : Create a separate new matrix that summarizes the additional risk factors for this firm launching a management consultancy or legal services line.
Read human rights : What does "universality" mean in terms of human rights?
Discuss heavy haze is present in the welding area : Discuss Heavy haze is present in the welding area. Individuals wearing half-mask air-purifying respirators have full beards.
What is a quality improvement plan : Why do healthcare facilities create improvement plans? Why would you recommend the facility create and implement a QI plan?

Reviews

len1849607

2/5/2018 5:56:33 AM

Grading: (you only need to submit hw3_test.py) 20% for mocking the required objects correctly 20% for the findFile cases 40% for the testSubmission cases Style: 10% proper comments for the new code you write, explaining what the mocking is supposed to accomplish 10% for proper variable or function names for new names you are defining – have them mean something

len1849607

2/5/2018 5:56:20 AM

Homework 3 due: February 9, 11:59pm using Blackboard. (You probably don't need to zip up anything since it's likely you are doing this in one file.) This is an individual assignment. · 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 so you are going to mock various parts of this problem so you can do some early testing.]

Write a Review

Python Programming Questions & Answers

  Write a python program that prints out a table

Write a Python program that prints out a table of values of all even powers of 2 from 2**0 through 2**32. For each value, print the value in decimal, hexadecimal, and binary.

  Design an application in python

Design an application in Python- The application would generate a set of 100 integers in a random manner in the range of 50 to 150 including both the numbers in the range

  How does the given change your programming capabilities

CS 192- Considering the lessons on menu logic and the use of arrays and loops, how does this change your programming capabilities? What kind of programs can you now create utilizing these powerful programming tools?

  Write a python program that will index a set of documents

You are going to write a python program that will index a set of documents and build a function to search through these documents using the index

  Write a python script that reads and analyses the data

ICT702 Task 2 - Apply relevant Python programming concepts to a data analysis challenge - Read data from real sources and wrangle it into the form you need

  Two-dimensional word puzzle

Write a python function called find_words that finds and prints the list of valid words in a two-dimensional word puzzle

  Write a program to read data from summary table

Write a program to: Read data from "SUMMARY" table on FTSE 100 index web page (sea Fig 1) then save them into your Python code

  Calculate the accuracy of your linear classifier

Plot X,Y and the decision boundary. Make sure that you use a good plotting technique so that it is easy to distinguish which datapoint is X and which is Y. Calculate the accuracy of your linear classifier.

  Create a custom python module

Write a program named program51.py that defines a value-returning function named cuber that returns both the surface area and volume of a cube. A cube is a rectangular prism with all sides equal.

  Code a console-based program in python

CP1404/CP5632 2016 SP2/22/52 Assignment 1 - Shopping List 1.0. You are to plan and then code a console-based program in Python 3, as described in the following information and sample output. This assignment will help you build skills using selectio..

  Implement functions for insertion sort

Implement functions for Insertion sort and bubble sort in python programming language and a function that calculates the function execution time.

  Define an init method that has one parameter named self

Define an init method that has one parameter named "self." In the init method, create an instance variable named dice that holds an empty list.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd