Checking your account

You can read the lesson while its saved answers and constructions load. Learning controls will open once that work is ready.

Python Testing and Project Tools

Find invalid report settings

Coding challenges

BOTIE

Return complete environment rows with invalid timeout_seconds. Read that column, turn whole-number text into numbers, and check the range. Reverse the acceptance decisions so Keep flagged entries returns rejected rows. The first example should return an empty list.
Ready to test
0 passed · 0 failed · 3 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.

Try your own inputs

Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Return complete environment rows with invalid timeout_seconds. Read that column, turn whole-number text into numbers, and check the range. Reverse the acceptance decisions so Keep flagged entries returns rejected rows. The first example should return an empty list.

Moving a setting outside the source code introduces new ways to enter an invalid value.

Read timeout_seconds from each row. The number reader produces null for unreadable text. The range check marks accepted values; reverse its decisions to keep the rejected rows.

Examples and results
Timeout settings by environment
  1. environment
    local
    timeout_seconds
    "12"
  2. environment
    production
    timeout_seconds
    "30"
Smallest allowed timeout in seconds
1
Largest allowed timeout in seconds
60
Required result
[]
Timeout settings by environment
  1. environment
    local
    timeout_seconds
    fast
  2. environment
    production
    timeout_seconds
    "12.5"
Smallest allowed timeout in seconds
1
Largest allowed timeout in seconds
60
Required result
  1. environment
    local
    timeout_seconds
    fast
  2. environment
    production
    timeout_seconds
    "12.5"
Timeout settings by environment
  1. environment
    local
    timeout_seconds
    "1"
  2. environment
    production
    timeout_seconds
    "60"
Smallest allowed timeout in seconds
1
Largest allowed timeout in seconds
60
Required result
[]
Try a fresh construction

This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.

Stuck? Inspect a worked construction

The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.

Assumptions and test precision

The blocks use supplied settings and a small whole-number parser. They do not read environment variables or secrets. The Python task implements its stated configuration rules. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

A smaller deployment limit

This check uses the pieces from “Check each environment setting”.

BOTIE

The allowed timeout range changes to 2 through 8 seconds. Local is configured as "4" and production as "12". Both are readable whole-number text.
Timeout settings by environment
  1. environment
    local
    timeout_seconds
    "4"
  2. environment
    production
    timeout_seconds
    "12"
Smallest allowed timeout in seconds
2
Largest allowed timeout in seconds
8

Saving your prediction runs your current construction on these inputs and checks the earlier examples too.

Build a construction in the workspace above first. This case will test those pieces.

Which setting values belong in a public diagnostic, and which should stay private?

Reject invalid configuration before starting the work that depends on it.

The blocks use supplied settings and a small whole-number parser. They do not read environment variables or secrets. The Python task implements its stated configuration rules.

Continue the courseFormatting, Linting, and Type Checks →
← Python Environments and Dependencies