Skip to content

Day 17 — Add basic tests for service CLI #7

Description

@Kirill-A-dev

Day 17 — Add basic tests for service CLI

Goal

Add basic automated tests for the service CLI project.

The goal is to start practicing testing and make sure the core service functions work correctly after refactoring and error handling.

Tasks

  • Create a new folder day17
  • Copy service_cli.py and services.json from day16
  • Create a test_service_cli.py file
  • Review the current functions:
    • load_services()
    • save_services()
    • reset_services()
    • list_services()
    • show_status()
    • start_service()
    • stop_service()
  • Add basic tests for service data changes
  • Test that start_service() changes service status to running
  • Test that stop_service() changes service status to stopped
  • Test that reset_services() restores default services
  • Test that invalid JSON is handled safely
  • Run tests manually
  • Add day17/README.md
  • Update main README.md

Practice topics

  • Basic testing
  • Test files
  • Assertions
  • Function behavior
  • Test data
  • Defensive programming checks
  • Regression testing

Expected result

The project should include basic tests that verify the service CLI logic.

Example:

python3 test_service_cli.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions