Skip to content
Snippets Groups Projects
Commit 457459fb authored by Erik Reid's avatar Erik Reid
Browse files

add test for junosspace loading utility

parent 32af0a13
No related branches found
No related tags found
No related merge requests found
...@@ -12,3 +12,4 @@ requests ...@@ -12,3 +12,4 @@ requests
pytest pytest
pytest-mock pytest-mock
responses
...@@ -32,9 +32,6 @@ def data_config_filename(tmp_dir_name): ...@@ -32,9 +32,6 @@ def data_config_filename(tmp_dir_name):
"oid_list.conf": os.path.join( "oid_list.conf": os.path.join(
tmp_dir_name, tmp_dir_name,
"oid_list.conf"), "oid_list.conf"),
"routers_community.conf": os.path.join(
tmp_dir_name,
"routers_community.conf"),
"ssh": { "ssh": {
"username": "uSeR-NaMe", "username": "uSeR-NaMe",
"private-key": "private-key-filename", "private-key": "private-key-filename",
...@@ -44,6 +41,11 @@ def data_config_filename(tmp_dir_name): ...@@ -44,6 +41,11 @@ def data_config_filename(tmp_dir_name):
"hostname": "xxxxxx", "hostname": "xxxxxx",
"port": 6379 "port": 6379
}, },
"junosspace": {
"api": "bogus-url",
"username": "bogus-username",
"password": "bogus-password"
},
"infinera-dna": [ "infinera-dna": [
{"name": "name1", "address": "123.456.789.0"}, {"name": "name1", "address": "123.456.789.0"},
{"name": "name2", "address": "012.345.678.9"}, {"name": "name2", "address": "012.345.678.9"},
...@@ -61,11 +63,6 @@ def data_config_filename(tmp_dir_name): ...@@ -61,11 +63,6 @@ def data_config_filename(tmp_dir_name):
config['oid_list.conf'] 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") filename = os.path.join(tmp_dir_name, "config.json")
with open(filename, "w") as f: with open(filename, "w") as f:
f.write(json.dumps(config)) f.write(json.dumps(config))
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment