Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Validate API Test Coverage

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Validate API Test Coverage. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given a list of expected API test cases and a list of executed test results, write a function that returns True if the automated test run is reliable and False otherwise. A run is reliable only if every expected endpoint appears at least once, every required status code for that endpoint is covered, and no executed test for those required checks has passed = False.

Constraints

  • 1 <= len(expected) <= 10^3
  • 1 <= total required status codes <= 10^4
  • 0 <= len(results) <= 2 * 10^4
  • Endpoint strings are non-empty
  • Status codes are integers in the HTTP range

Function Signature

def is_reliable_test_run(expected, results):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output