Courseiva

200-901 Infrastructure and Automation Practice Question

A developer is writing a unit test for a Python function that calls the Cisco DNA Center API to fetch device health. The test must not perform real network calls and should verify that the function parses a sample JSON response correctly. Which approach best satisfies these requirements?

⚠ Common exam trap

The trap here is equating 'no live production system' with 'no network calls', when even a replay proxy or sandbox still makes real HTTP requests that break unit-test isolation.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Use the unittest.mock library to patch the function's requests call so it returns a mock response object whose json method yields the sample data.

Unit tests should isolate the code under test from external systems. Patching the HTTP call with unittest.mock replaces the real request with a mock response containing sample JSON, so the parsing logic is exercised deterministically without any network traffic. Proxies, live sandboxes, and retry tuning all leave real calls in place.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Increase the requests timeout value and retry on failure so the test tolerates slow DNA Center responses.

    Why it's wrong here

    Adjusting timeouts and retries does not remove the real network calls; it only makes the test slower and more tolerant of a flaky external service. The parsing logic is still exercised against live data rather than a controlled sample, so the test cannot reliably verify correct JSON handling.

  • ✗

    Run the test against a live Cisco DNA Center sandbox and assert that the returned health values are non-empty.

    Why it's wrong here

    Hitting a live sandbox performs real network calls and makes the test depend on external availability and data. Results change as devices change state, so the test is neither isolated nor deterministic. This directly violates the requirement that the test must not perform real network calls.

  • ✗

    Point the function at a recorded HTTP proxy that replays previously captured DNA Center responses.

    Why it's wrong here

    A replay proxy still involves real HTTP calls over the network stack, even if responses are canned. It introduces external infrastructure and latency into a unit test, and failures in the proxy can break tests unrelated to the code. This does not satisfy the requirement to avoid network calls in a unit test.

  • ✓

    Use the unittest.mock library to patch the function's requests call so it returns a mock response object whose json method yields the sample data.

    Why this is correct

    Patching the HTTP call with unittest.mock prevents real network traffic and lets the test supply a controlled response object. The function under test then exercises its parsing logic against known JSON, producing deterministic results. This isolates the unit under test and satisfies both the no-network and parsing-verification requirements.

About these practice questions

Courseiva writes every 200-901 question from scratch — 975 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Cisco exam blueprint

This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.