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

Stop an import from running the report

Coding challenges

BOTIE

Return the rows that need moving behind the main entry point: kind must be "report run" and when must be "import". Match each field separately, require both decisions, then keep those rows. The first result should identify Read readings.csv.
Ready to test
0 passed · 0 failed · 2 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 the rows that need moving behind the main entry point: kind must be "report run" and when must be "import". Match each field separately, require both decisions, then keep those rows. The first result should identify Read readings.csv.

A caller wants the calculation, but importing it also starts the report.

Read kind and when from the same rows. Configure one text matcher for report run and another for import. Require both, then keep the original steps.

Examples and results
Steps currently performed by the report module
  1. step
    Define summarize_alerts
    kind
    definition
    when
    import
  2. step
    Read readings.csv
    kind
    report run
    when
    import
  3. step
    Print the report
    kind
    report run
    when
    main
Required result
  1. step
    Read readings.csv
    kind
    report run
    when
    import
Steps currently performed by the report module
  1. step
    Define summarize_alerts
    kind
    definition
    when
    import
  2. step
    Read readings.csv
    kind
    report run
    when
    main
  3. step
    Print the report
    kind
    report run
    when
    main
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 rows describe a small Python module. These blocks inspect that description; the Python challenge separates reusable helpers from the application entry point. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

A new delivery step runs too early

This check uses the pieces from “Find report work that runs during import”.

BOTIE

The module now reads a new batch and sends a completed report during import. Its ordinary convert_report definition also remains at module scope.
Steps currently performed by the report module
  1. step
    Define convert_report
    kind
    definition
    when
    import
  2. step
    Read the new batch
    kind
    report run
    when
    import
  3. step
    Send the completed report
    kind
    report run
    when
    import

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 actions belong in the entry point of your own report program?

Keep reusable definitions available without starting the application.

The rows describe a small Python module. These blocks inspect that description; the Python challenge separates reusable helpers from the application entry point.

Continue the coursePython Environments and Dependencies →
← Dependency Injection and Test Doubles