Select Git revision
test_inventory.py
test_inventory.py 1.64 KiB
import tempfile
import responses
from mapping_provider.backends import cache, inventory
from .common import load_test_data
@responses.activate
def test_inventory_service_download():
"""
tmp bogus test - just to have something
"""
inventory_base_uri = 'https://dummy-hostname.dummy.domain'
reporting_base_uri = 'https://another-dummy-hostname.dummy.domain'
responses.add(
method=responses.GET,
url=f'{inventory_base_uri}/poller/interfaces',
json=load_test_data('poller-interfaces.json')
)
responses.add(
method=responses.GET,
url=f'{reporting_base_uri}/scid/current',
json=load_test_data('scid-current.json')
)
responses.add(
method=responses.GET,
url=f'{inventory_base_uri}/map/services',
json=load_test_data('inprov-services.json')
)
with tempfile.TemporaryDirectory() as tmp_dir:
cache.init(tmp_dir)
inventory._load_all_inventory(
inventory_base_uri='https://dummy-hostname.dummy.domain',
reporting_base_uri='https://another-dummy-hostname.dummy.domain')
# assert os.path.exists(os.path.join(tmp_dir, services.POLLER_INTERFACES_CACHE_FILENAME))
cached_data = cache.get(inventory.INPROV_POLLER_INTERFACES_CACHE_FILENAME)
assert cached_data == load_test_data('poller-interfaces.json')
cached_data = cache.get(inventory.INPROV_MAP_SERVICES_CACHE_FILENAME)
assert cached_data == load_test_data('inprov-services.json')
cached_data = cache.get(inventory.REPORTING_SCID_CURRENT_CACHE_FILENAME)
assert cached_data == load_test_data('scid-current.json')