Skip to content

Commit 133edf8

Browse files
committed
test(integration): add nsconfig, hwinfo, debug tests
- Add nsconfig test (check for unsaved config changes) - Add hwinfo test (display hardware info) - Add debug test (show raw API response) - Update nsconfig fixture with configchanged field 19 integration tests total now (10 original + 9 new).
1 parent 30af228 commit 133edf8

2 files changed

Lines changed: 77 additions & 1 deletion

File tree

tests/mocks/fixtures/config/nsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"ftpportrange": "1024-65535",
2424
"crportrange": "1024-65535",
2525
"timezone": "GMT",
26-
"lastconfigchangedtime": "Wed Dec 4 10:30:15 2024"
26+
"lastconfigchangedtime": "Wed Dec 4 10:30:15 2024",
27+
"configchanged": false
2728
}
2829
}

tests/test_integration_with_mock_api.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,81 @@ def test_below_check_critical(self, mock_nitro_server):
418418
assert "disk1perusage" in result.message
419419

420420

421+
class TestNSConfigCommandWithMockAPI:
422+
"""Test nsconfig command against mock API"""
423+
424+
def test_nsconfig_no_changes(self, mock_nitro_server):
425+
"""Test nsconfig when no unsaved changes"""
426+
with NITROClient(
427+
hostname=mock_nitro_server.host,
428+
port=mock_nitro_server.port,
429+
username="nsroot",
430+
password="nsroot",
431+
ssl=False,
432+
) as client:
433+
args = Namespace(command="nsconfig")
434+
435+
from check_netscaler.commands.nsconfig import NSConfigCommand
436+
437+
command = NSConfigCommand(client, args)
438+
result = command.execute()
439+
440+
assert result.status == STATE_OK
441+
assert "No unsaved configuration changes" in result.message
442+
443+
444+
class TestHWInfoCommandWithMockAPI:
445+
"""Test hwinfo command against mock API"""
446+
447+
def test_hwinfo_display(self, mock_nitro_server):
448+
"""Test hwinfo displays hardware information"""
449+
with NITROClient(
450+
hostname=mock_nitro_server.host,
451+
port=mock_nitro_server.port,
452+
username="nsroot",
453+
password="nsroot",
454+
ssl=False,
455+
) as client:
456+
args = Namespace(command="hwinfo")
457+
458+
from check_netscaler.commands.hwinfo import HWInfoCommand
459+
460+
command = HWInfoCommand(client, args)
461+
result = command.execute()
462+
463+
assert result.status == STATE_OK
464+
assert "Platform" in result.message or "CPU" in result.message
465+
466+
467+
class TestDebugCommandWithMockAPI:
468+
"""Test debug command against mock API"""
469+
470+
def test_debug_raw_response(self, mock_nitro_server):
471+
"""Test debug shows raw API response"""
472+
with NITROClient(
473+
hostname=mock_nitro_server.host,
474+
port=mock_nitro_server.port,
475+
username="nsroot",
476+
password="nsroot",
477+
ssl=False,
478+
) as client:
479+
args = Namespace(
480+
command="debug",
481+
objecttype="lbvserver",
482+
objectname="lb_web",
483+
endpoint="config",
484+
)
485+
486+
from check_netscaler.commands.debug import DebugCommand
487+
488+
command = DebugCommand(client, args)
489+
result = command.execute()
490+
491+
assert result.status == STATE_OK
492+
# Debug command returns JSON response
493+
assert "lbvserver" in result.message or "lb_web" in result.message
494+
495+
421496
class TestLicenseCommandWithMockAPI:
422497
"""Test license command against mock API"""
423498

0 commit comments

Comments
 (0)