From 343f223a8362eb4db168f4126ee289b22581599b Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 20 Mar 2019 17:04:02 +0800 Subject: [PATCH] Fix tests after deactivating the embedded shell for Ethernet switch. Ref #1424 #1556 --- .../compute/dynamips/test_ethernet_switch.py | 16 ++-- tests/utils/asyncio/test_embed_shell.py | 84 +++++++++---------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/tests/compute/dynamips/test_ethernet_switch.py b/tests/compute/dynamips/test_ethernet_switch.py index 47e7c361..dd0d5551 100644 --- a/tests/compute/dynamips/test_ethernet_switch.py +++ b/tests/compute/dynamips/test_ethernet_switch.py @@ -16,7 +16,7 @@ # along with this program. If not, see . from tests.utils import AsyncioMagicMock -from gns3server.compute.dynamips.nodes.ethernet_switch import EthernetSwitchConsole +#from gns3server.compute.dynamips.nodes.ethernet_switch import EthernetSwitchConsole from gns3server.compute.nios.nio_udp import NIOUDP @@ -28,10 +28,10 @@ def test_mac_command(async_run): node.nios[0].name = "Ethernet0" node.nios[1] = NIOUDP(55, "127.0.0.1", 56) node.nios[1].name = "Ethernet1" - node._hypervisor.send = AsyncioMagicMock(return_value=["0050.7966.6801 1 Ethernet0", "0050.7966.6802 1 Ethernet1"]) - console = EthernetSwitchConsole(node) - assert async_run(console.mac()) == \ - "Port Mac VLAN\n" \ - "Ethernet0 00:50:79:66:68:01 1\n" \ - "Ethernet1 00:50:79:66:68:02 1\n" - node._hypervisor.send.assert_called_with("ethsw show_mac_addr_table Test") + #node._hypervisor.send = AsyncioMagicMock(return_value=["0050.7966.6801 1 Ethernet0", "0050.7966.6802 1 Ethernet1"]) + #console = EthernetSwitchConsole(node) + #assert async_run(console.mac()) == \ + # "Port Mac VLAN\n" \ + # "Ethernet0 00:50:79:66:68:01 1\n" \ + # "Ethernet1 00:50:79:66:68:02 1\n" + #node._hypervisor.send.assert_called_with("ethsw show_mac_addr_table Test") diff --git a/tests/utils/asyncio/test_embed_shell.py b/tests/utils/asyncio/test_embed_shell.py index 3f53c472..706292c3 100644 --- a/tests/utils/asyncio/test_embed_shell.py +++ b/tests/utils/asyncio/test_embed_shell.py @@ -17,7 +17,7 @@ import asyncio -from gns3server.utils.asyncio.embed_shell import EmbedShell +#from gns3server.utils.asyncio.embed_shell import EmbedShell #FIXME: this is broken with recent Python >= 3.6 # def test_embed_shell_help(async_run): @@ -39,44 +39,44 @@ from gns3server.utils.asyncio.embed_shell import EmbedShell # assert async_run(app._parse_command('? hello')) == 'hello: The hello world function\n\nThe hello usage\n' -def test_embed_shell_execute(async_run): - class Application(EmbedShell): - - async def hello(self): - """ - The hello world function - - The hello usage - """ - return 'world' - reader = asyncio.StreamReader() - writer = asyncio.StreamReader() - app = Application(reader, writer) - assert async_run(app._parse_command('hello')) == 'world' - - -def test_embed_shell_welcome(async_run, loop): - reader = asyncio.StreamReader() - writer = asyncio.StreamReader() - app = EmbedShell(reader, writer, welcome_message="Hello") - task = loop.create_task(app.run()) - assert async_run(writer.read(5)) == b"Hello" - task.cancel() - try: - loop.run_until_complete(task) - except asyncio.CancelledError: - pass - - -def test_embed_shell_prompt(async_run, loop): - reader = asyncio.StreamReader() - writer = asyncio.StreamReader() - app = EmbedShell(reader, writer) - app.prompt = "gbash# " - task = loop.create_task(app.run()) - assert async_run(writer.read(7)) == b"gbash# " - task.cancel() - try: - loop.run_until_complete(task) - except asyncio.CancelledError: - pass +# def test_embed_shell_execute(async_run): +# class Application(EmbedShell): +# +# async def hello(self): +# """ +# The hello world function +# +# The hello usage +# """ +# return 'world' +# reader = asyncio.StreamReader() +# writer = asyncio.StreamReader() +# app = Application(reader, writer) +# assert async_run(app._parse_command('hello')) == 'world' +# +# +# def test_embed_shell_welcome(async_run, loop): +# reader = asyncio.StreamReader() +# writer = asyncio.StreamReader() +# app = EmbedShell(reader, writer, welcome_message="Hello") +# task = loop.create_task(app.run()) +# assert async_run(writer.read(5)) == b"Hello" +# task.cancel() +# try: +# loop.run_until_complete(task) +# except asyncio.CancelledError: +# pass +# +# +# def test_embed_shell_prompt(async_run, loop): +# reader = asyncio.StreamReader() +# writer = asyncio.StreamReader() +# app = EmbedShell(reader, writer) +# app.prompt = "gbash# " +# task = loop.create_task(app.run()) +# assert async_run(writer.read(7)) == b"gbash# " +# task.cancel() +# try: +# loop.run_until_complete(task) +# except asyncio.CancelledError: +# pass