Add focused unit tests for the MikroTik parser helpers

Open Beginner friendly
#54 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
90/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
testing

Research direction

Start by reading parsers/mikrotik_parser.py and compare assertion patterns in tests/test_cisco_topology_validation.py. Create tests/test_mikrotik_parser.py with synthetic inputs covering normalization, key/value parsing, ping, NTP, and clock helpers, including PASS, FAIL, and WARNING contracts. Run the focused tests, full pytest, and python network_lab.py --task report-index; done means all acceptance criteria pass without device or credential access.

Written by the indexing model from the issue text.

Description

enhancement good first issue

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.

Dominant language
Python
Stars
0
Forks
1
Avg merge
1h 38m
Merged PRs (30d)
39

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Robinlee0929/Network_Automation_Lab

All issues in Robinlee0929/Network_Automation_Lab

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.