-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make show command eq dump * add tests Bug-Url: #1225
- Loading branch information
Showing
3 changed files
with
76 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
from pyroute2 import AsyncIPRoute | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"command,kwarg", | ||
[ | ||
("dump", {"table": 255}), | ||
("show", {"table": 255}), | ||
("dump", {"match": {"table": 255}}), | ||
("show", {"match": {"table": 255}}), | ||
], | ||
) | ||
@pytest.mark.asyncio | ||
async def test_route_filter(async_ipr, command, kwarg): | ||
assert set( | ||
[ | ||
route.get('table') | ||
async for route in await async_ipr.route(command, **kwarg) | ||
] | ||
) == set([255]) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"command,kwarg", | ||
[ | ||
("dump", {"table": 255, "family": 1}), | ||
("show", {"table": 255, "family": 1}), | ||
], | ||
) | ||
@pytest.mark.asyncio | ||
async def test_route_filter_strict(command, kwarg): | ||
async with AsyncIPRoute(strict_check=True) as ipr: | ||
assert set( | ||
[ | ||
route.get('table') | ||
async for route in await ipr.route(command, **kwarg) | ||
] | ||
) == set([255]) |
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,32 @@ | ||
import pytest | ||
|
||
from pyroute2 import IPRoute | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"command,kwarg", | ||
[ | ||
("dump", {"table": 255}), | ||
("show", {"table": 255}), | ||
("dump", {"match": {"table": 255}}), | ||
("show", {"match": {"table": 255}}), | ||
], | ||
) | ||
def test_route_filter(sync_ipr, command, kwarg): | ||
assert set( | ||
[route.get('table') for route in sync_ipr.route(command, **kwarg)] | ||
) == set([255]) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"command,kwarg", | ||
[ | ||
("dump", {"table": 255, "family": 1}), | ||
("show", {"table": 255, "family": 1}), | ||
], | ||
) | ||
def test_route_filter_strict(command, kwarg): | ||
with IPRoute(strict_check=True) as ipr: | ||
assert set( | ||
[route.get('table') for route in ipr.route(command, **kwarg)] | ||
) == set([255]) |