2017-06-01 05:44:47 +00:00
|
|
|
# -*- coding: UTF-8 -*-
|
2017-05-31 18:55:36 +00:00
|
|
|
|
2018-01-26 14:23:44 +00:00
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
2017-05-31 20:34:00 +00:00
|
|
|
|
2017-05-31 18:55:36 +00:00
|
|
|
from tests.support.unit import TestCase
|
2017-06-01 08:47:26 +00:00
|
|
|
from tests.support.unit import skipIf
|
2017-05-31 18:55:36 +00:00
|
|
|
from salt.beacons.network_settings import ATTRS
|
2017-06-01 08:47:26 +00:00
|
|
|
try:
|
|
|
|
from pyroute2 import IPDB
|
|
|
|
HAS_PYROUTE2 = True
|
|
|
|
except ImportError:
|
|
|
|
HAS_PYROUTE2 = False
|
2017-05-31 18:55:36 +00:00
|
|
|
|
|
|
|
|
2017-06-01 08:47:26 +00:00
|
|
|
@skipIf(not HAS_PYROUTE2, 'no pyroute2 installed, skipping')
|
2017-05-31 18:55:36 +00:00
|
|
|
class Pyroute2TestCase(TestCase):
|
|
|
|
|
|
|
|
def test_interface_dict_fields(self):
|
|
|
|
with IPDB() as ipdb:
|
|
|
|
for attr in ATTRS:
|
2017-06-01 08:47:26 +00:00
|
|
|
# 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.
|
2017-05-31 18:55:36 +00:00
|
|
|
self.assertIn(attr, ipdb.interfaces[1])
|