Strengthen logging assertions for refused REST activations

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

Open netbox_scripts/tests/api/test_projects.py and extend test_a_refused_activation_returns_a_fixed_message_and_logs_its_reason. Read the existing assertLogs() checks, then assert that the captured record has WARNING level and no exception information. Run that test; it is done when it still checks the message and also fails if the log level or exception information is wrong.

Written by the indexing model from the issue text.

Description

app: scripts status: backlog type: housekeeping
Proposed Changes

Extend test_a_refused_activation_returns_a_fixed_message_and_logs_its_reason in netbox_scripts/tests/api/test_projects.py to assert that the captured log record has a WARNING level and contains no exception information, in addition to the existing message assertions.

Justification

Expected activation refusals are logged at WARNING without a traceback. However, assertLogs() also captures records at higher severity levels, so changing the logging call to logger.exception() would not cause the existing tests to fail.

Explicitly checking the log level and the absence of exception information ensures that this intended behavior remains covered by the tests.

Dominant language
Python
Stars
8
Forks
0
Avg merge
12h 46m
Merged PRs (30d)
83

Getting set up

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 netbox-community/netbox-scripts

All issues in netbox-community/netbox-scripts

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.