-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
snmp-subagent changes for bookworm upgrade (#313)
* remove loop argument from asyncio APIs * Add test for code coverage Taken from "commit 2dbbb5c" --------- Co-authored-by: Qi Luo <qiluo-msft@users.noreply.github.com>
- Loading branch information
1 parent
204d97d
commit f652948
Showing
4 changed files
with
33 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import asyncio | ||
import os | ||
import sys | ||
import time | ||
from unittest import TestCase | ||
|
||
modules_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
sys.path.insert(0, os.path.join(modules_path, 'src')) | ||
|
||
import ax_interface | ||
|
||
class SonicMIB(metaclass=ax_interface.mib.MIBMeta): | ||
""" | ||
Test | ||
""" | ||
|
||
class TestAgentLoop(TestCase): | ||
|
||
async def delayed_shutdown(self, agent): | ||
await asyncio.sleep(5) | ||
await agent.shutdown() | ||
|
||
def test_agent_loop(self): | ||
event_loop = asyncio.get_event_loop() | ||
agent = ax_interface.Agent(SonicMIB, 5, event_loop) | ||
event_loop.create_task(self.delayed_shutdown(agent)) | ||
event_loop.run_until_complete(agent.run_in_event_loop()) |