summaryrefslogtreecommitdiff
path: root/src/tests/test_template.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-04-05 15:36:44 +0200
committerChristian Poessinger <christian@poessinger.com>2021-04-05 15:37:04 +0200
commit23598fc082fcf0c02e113586bfc615583a05d2f3 (patch)
treede2198d7d2ed9d2c9659367a6fd473af060a1f23 /src/tests/test_template.py
parent49cfd4e0c56a8b7a85128bfdb4a4e19157137129 (diff)
downloadvyos-1x-23598fc082fcf0c02e113586bfc615583a05d2f3.tar.gz
vyos-1x-23598fc082fcf0c02e113586bfc615583a05d2f3.zip
vyos.template: T3418: add new is_interface helper function
Diffstat (limited to 'src/tests/test_template.py')
-rw-r--r--src/tests/test_template.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tests/test_template.py b/src/tests/test_template.py
index 7800d007f..67c0fe84a 100644
--- a/src/tests/test_template.py
+++ b/src/tests/test_template.py
@@ -14,13 +14,23 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import os
import vyos.template
+
from unittest import TestCase
class TestVyOSTemplate(TestCase):
def setUp(self):
pass
+ def test_is_interface(self):
+ for interface in ['lo', 'eth0']:
+ if os.path.exists(f'/sys/class/net/{interface}'):
+ self.assertTrue(vyos.template.is_interface(interface))
+ else:
+ self.assertFalse(vyos.template.is_interface(interface))
+ self.assertFalse(vyos.template.is_interface('non-existent'))
+
def test_is_ip(self):
self.assertTrue(vyos.template.is_ip('192.0.2.1'))
self.assertTrue(vyos.template.is_ip('2001:db8::1'))