Skip to content
Snippets Groups Projects
Select Git revision
  • 244e753db27ae794d9c67f481eadfebb111e16a8
  • develop default
  • master protected
  • NGM-30-hover-popup
  • svg-test
  • master-conflicted
  • 0.13
  • 0.12
  • 0.11
  • 0.10
  • 0.9
  • 0.8
  • 0.7
  • 0.6
  • 0.5
  • 0.4
  • 0.3
  • 0.2
  • 0.1
19 results

test_inventory.py

Blame
  • 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')