diff --git a/requirements.txt b/requirements.txt index 91780209631614baa993d350956537c79fde8ca1..ff5a3796d6da2c9e606022c04fc5806a5f353eb5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,4 @@ requests pytest pytest-mock +responses diff --git a/test/conftest.py b/test/conftest.py index 52fa1af377207a4546aa9d853ecb58ef505d239f..748d607fdbe2bcbb3c8871f832bba3fdb7ee59a7 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -32,9 +32,6 @@ def data_config_filename(tmp_dir_name): "oid_list.conf": os.path.join( tmp_dir_name, "oid_list.conf"), - "routers_community.conf": os.path.join( - tmp_dir_name, - "routers_community.conf"), "ssh": { "username": "uSeR-NaMe", "private-key": "private-key-filename", @@ -44,6 +41,11 @@ def data_config_filename(tmp_dir_name): "hostname": "xxxxxx", "port": 6379 }, + "junosspace": { + "api": "bogus-url", + "username": "bogus-username", + "password": "bogus-password" + }, "infinera-dna": [ {"name": "name1", "address": "123.456.789.0"}, {"name": "name2", "address": "012.345.678.9"}, @@ -61,11 +63,6 @@ def data_config_filename(tmp_dir_name): config['oid_list.conf'] ) - shutil.copyfile( - os.path.join(TEST_DATA_DIRNAME, 'routers_community.conf'), - config['routers_community.conf'] - ) - filename = os.path.join(tmp_dir_name, "config.json") with open(filename, "w") as f: f.write(json.dumps(config)) diff --git a/test/test_junosspace_io.py b/test/test_junosspace_io.py new file mode 100644 index 0000000000000000000000000000000000000000..39d8288987198effde8a5d4fba2c39a2b03f3e5d --- /dev/null +++ b/test/test_junosspace_io.py @@ -0,0 +1,26 @@ +import os + +import responses + +import inventory_provider +from inventory_provider import juniper + +TEST_DATA_FILENAME = os.path.realpath(os.path.join( + inventory_provider.__path__[0], + '..', + 'test', + 'data', + 'junosspace-devices.xml')) + + +@responses.activate +def test_junosspace_devices_parsing(data_config): + data_config['junosspace']['api'] = 'http://sabababa' + with open(TEST_DATA_FILENAME) as f: + responses.add( + method=responses.GET, + url = data_config['junosspace']['api'] + '/device-management/devices', + body=f.read()) + + doc = juniper.load_routers_from_junosspace(data_config['junosspace']) + assert doc