Skip to content

Commit

Permalink
Simplified test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Aug 26, 2024
1 parent 8648c37 commit 895b55a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
21 changes: 3 additions & 18 deletions tests/hlapi/asyncio/agent/ntforg/test_v3-inform.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,16 @@
@pytest.mark.asyncio
async def test_send_v3_inform():
async with ManagerContextManager():
# Assemble MIB browser
mibBuilder = builder.MibBuilder()
mibViewController = view.MibViewController(mibBuilder)
compiler.addMibCompiler(
mibBuilder,
sources=[
"file:///usr/share/snmp/mibs",
"https://mibs.pysnmp.com/asn1/@mib@",
],
)

# Pre-load MIB modules we expect to work with
mibBuilder.loadModules("SNMPv2-MIB")

snmpEngine = SnmpEngine()
snmpEngine.cache["mibViewController"] = mibViewController
errorIndication, errorStatus, errorIndex, varBinds = await sendNotification(
snmpEngine,
UsmUserData("usr-md5-des", "authkey1", "privkey1"),
UdpTransportTarget(("localhost", MANAGER_PORT)),
ContextData(),
"inform",
NotificationType(ObjectIdentity("1.3.6.1.6.3.1.1.5.2")).addVarBinds(
("1.3.6.1.2.1.1.1.0", OctetString("my system"))
),
NotificationType(ObjectIdentity("1.3.6.1.6.3.1.1.5.2"))
.loadMibs("SNMPv2-MIB")
.addVarBinds(("1.3.6.1.2.1.1.1.0", OctetString("my system"))),
)

assert errorIndication is None
Expand Down
16 changes: 3 additions & 13 deletions tests/hlapi/asyncio/manager/cmdgen/test_v1_next.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,15 @@

@pytest.mark.asyncio
async def test_v1_next():
# Assemble MIB browser
mibBuilder = builder.MibBuilder()
mibViewController = view.MibViewController(mibBuilder)
compiler.addMibCompiler(
mibBuilder,
sources=["file:///usr/share/snmp/mibs", "https://mibs.pysnmp.com/asn1/@mib@"],
)

# Pre-load MIB modules we expect to work with
mibBuilder.loadModules("PYSNMP-MIB")

async with AgentContextManager():
with Slim(1) as slim:
slim.snmpEngine.cache["mibViewController"] = mibViewController
errorIndication, errorStatus, errorIndex, varBinds = await slim.next(
"public",
"localhost",
AGENT_PORT,
ObjectType(ObjectIdentity("SNMPv2-MIB", "sysDescr", 0)),
ObjectType(
ObjectIdentity("SNMPv2-MIB", "sysDescr", 0).loadMibs("PYSNMP-MIB")
),
)

assert errorIndication is None
Expand Down

0 comments on commit 895b55a

Please sign in to comment.