Robinlee0929 / Robinlee0929/Network_Automation_Lab

Add focused unit tests for the MikroTik parser helpers

Open Beginner friendly
#54 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Python
Stars
0
Forks
1
Avg merge
1h 38m
Merged PRs (30d)
39

Description

## 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.

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.