Skip to content

Commit ad0fea3

Browse files
committed
inital tests
1 parent 4ce56dc commit ad0fea3

5 files changed

Lines changed: 142 additions & 0 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# TODO: list...
2+
7. delete-devices <DeviceNames>
3+
4+
====
5+
how to set custom ports
6+
how to set netsim dir
7+
how to set ncsdir, nsorun, etc
8+
9+
====
10+
in templates ->
11+
download - true
12+
ned-links - list
13+
extract - true
14+
15+
"""
16+
In [10]: def abc(index=None, lazy_load=False):
17+
...: l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
18+
...: print(l)
19+
...: index = index or len(l)
20+
...: print(index)
21+
...: for i in l[:index]:
22+
...: print(i)
23+
...: if lazy_load:
24+
...: yield
25+
...: for i in l[index:]:
26+
...: print(i)
27+
...:
28+
29+
In [17]: def xyz():
30+
...: for i in abc(index=4, lazy_load=True):
31+
...: print('I am in-between')
32+
...:
33+
34+
In [18]: xyz()
35+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
36+
4
37+
0
38+
1
39+
2
40+
3
41+
I am in-between
42+
4
43+
5
44+
6
45+
7
46+
8
47+
9
48+
"""
49+
Testing -->
50+
Usage nwrap
51+
(template load -> basic is done)
52+
template load <fileName> [<username> <password>]
53+
delete-devices <DeviceNames>
54+
55+
56+
nso-packages-path: "/root/ncs-run-5.7/packages"
57+
download-neds: true
58+
neds:
59+
- https://earth.tail-f.com:8443/ncs-pkgs/cisco-iosxr/5.7.1/ncs-5.7.1-cisco-iosxr-7.38.4.signed.bin
60+
- https://earth.tail-f.com:8443/ncs-pkgs/cisco-ios/5.7.1/ncs-5.7.1-cisco-ios-6.77.10.signed.bin
61+
- https://earth.tail-f.com:8443/ncs-pkgs/cisco-nx/5.7.1/ncs-5.7.1-cisco-nx-5.22.8.signed.bin
62+
compile-neds: true
63+
start-devices: true
64+
add-to-nso: true
65+
add-authgroup-to-nso: true
66+
authgroup:
67+
type: system
68+
path: <authgroup-file-path>
69+
device-mode:
70+
prefix-based:
71+
cisco-ios-cli-6.77:
72+
count: 2
73+
prefix: ios
74+
cisco-iosxr-cli-7.38:
75+
count: 2
76+
prefix: xr
77+
cisco-nx-cli-5.22:
78+
count: 2
79+
prefix: nx
80+
load-day0-config: false
81+
config-path: "/root/ncs-run-5.7/config"
82+
config-files:
83+
- day0.xml
84+
- day1.xml

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from __future__ import absolute_import

tests/test_nwrap.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import pytest
2+
import logging
3+
import argparse
4+
import unittest
5+
6+
from _pytest.monkeypatch import MonkeyPatch
7+
8+
from netsim_wrapper import main
9+
10+
LOGGER = logging.getLogger(__name__)
11+
12+
# TODO: need to update
13+
def get_inputs():
14+
args = {
15+
'username': None,
16+
'password': None,
17+
'ext': None,
18+
'download': False,
19+
'verbosity': 0,
20+
'web': None,
21+
'substring': None,
22+
'proxy': None,
23+
'proxy_username': None,
24+
'proxy_password': None,
25+
'local': None,
26+
'global': None
27+
}
28+
return args
29+
30+
31+
@pytest.mark.run
32+
class TestNetsimWrapperVersion(unittest.TestCase):
33+
34+
def setUp(self):
35+
self.monkeypatch = MonkeyPatch()
36+
self.args = get_inputs()
37+
38+
def tearDown(self) -> None:
39+
self.monkeypatch.undo()
40+
return super().tearDown()
41+
42+
# @property
43+
# def applyPatch(self):
44+
# f = lambda x: argparse.Namespace(**self.args)
45+
# self.monkeypatch.setattr(argparse.ArgumentParser, 'parse_args', f)
46+
47+
@pytest.fixture(autouse=True)
48+
def inject_fixtures(self, capfd):
49+
self._capfd = capfd
50+
51+
def test_weblinks_version(self):
52+
self.args['version'] = True
53+
self.applyPatch
54+
run.main()
55+
out, err = self._capfd.readouterr()
56+
assert out.strip() == 'weblinks version: 2.0'
57+
del self.args['version']

0 commit comments

Comments
 (0)