Skip to content

Add focused unit tests for the MikroTik parser helpers #54

Description

@Robinlee0929

Context

parsers/mikrotik_parser.py provides pure helpers for output normalization, key/value parsing, ping results, NTP state, and clock state. The repository currently has no dedicated unit-test module for these helpers.

Focused tests will protect local parsing behavior without requiring RouterOS hardware, SSH, credentials, or private lab data.

Newcomer snapshot

  • Difficulty: Beginner / Intermediate
  • Scope: Small
  • Primary area: Python / pytest parser unit tests
  • Likely files: primarily a new tests/test_mikrotik_parser.py; parser changes require a separately documented defect
  • Python required: Yes
  • Node/npm required: No
  • Physical hardware required: No
  • Live device access required: No
  • Credentials required: No
  • External API/provider required: No
  • Task-time network access required: No, after local dependencies are installed
  • Start with: python -m pytest tests/test_mikrotik_parser.py
  • Before completion: run the focused parser tests, full pytest, and python network_lab.py --task report-index
  • Do not change: adapters, runners, SSH/device access, credentials handling, or parser implementation unless a separate clearly documented parser defect is discovered

Dependency installation may require internet access; the access fields above describe the task after local prerequisites are installed.

Scope

Add tests/test_mikrotik_parser.py using small, synthetic RouterOS-style strings.

This issue is test-only unless a separate, clearly documented parser defect is discovered during implementation.

Acceptance criteria

  • normalize_output() is covered for extra spaces, line breaks, and case normalization.
  • parse_key_value_output() is covered for multiple keys and blank lines.
  • parse_ping() is covered for successful, fully lost, malformed, and empty output.
  • parse_ntp() is covered for synchronized and unsynchronized states.
  • parse_clock() is covered for complete and missing timezone data.
  • Assertions verify the existing PASS, FAIL, and WARNING contracts.
  • Every fixture is synthetic and contains no credentials or private infrastructure.
  • Tests import only the parser module and do not invoke adapters, runners, SSH, or device access.

Suggested starting points

  • parsers/mikrotik_parser.py
  • tests/test_cisco_topology_validation.py as an example of parser-oriented assertions
  • New tests/test_mikrotik_parser.py

Validation

Run:

  • python -m pytest tests/test_mikrotik_parser.py
  • python -m pytest
  • python network_lab.py --task report-index

Safety boundary

Use inline or committed synthetic text only. The tests must not read credentials, contact a device, import an execution adapter, open SSH, or require a physical MikroTik router.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions