Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit tests: add pyroute2 interface dict test #41533

Merged
merged 4 commits into from Jun 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/unit/modules/test_pyroute2.py
@@ -0,0 +1,27 @@
# -*- coding: UTF-8 -*-

from __future__ import absolute_import

from tests.support.unit import TestCase
from tests.support.unit import skipIf
from salt.beacons.network_settings import ATTRS
try:
from pyroute2 import IPDB
HAS_PYROUTE2 = True
except ImportError:
HAS_PYROUTE2 = False


@skipIf(not HAS_PYROUTE2, 'no pyroute2 installed, skipping')
class Pyroute2TestCase(TestCase):

def test_interface_dict_fields(self):
with IPDB() as ipdb:
for attr in ATTRS:
# ipdb.interfaces is a dict-like object, that
# contains interface definitions. Interfaces can
# be referenced both with indices and names.
#
# ipdb.interfaces[1] is an interface with index 1,
# that is the loopback interface.
self.assertIn(attr, ipdb.interfaces[1])