def test_get_bgp_config(self, test_case):
        """Test get_bgp_config."""
        get_bgp_config = self.device.get_bgp_config()
        assert len(get_bgp_config) > 0

        for bgp_group in get_bgp_config.values():
            assert helpers.test_model(models.bgp_config_group, bgp_group)
            for bgp_neighbor in bgp_group.get('neighbors', {}).values():
                assert helpers.test_model(models.bgp_config_neighbor, bgp_neighbor)

        return get_bgp_config
    def test_get_network_instances(self, test_case):
        """Test get_network_instances method."""
        get_network_instances = self.device.get_network_instances()

        assert isinstance(get_network_instances, dict)
        for network_instance_name, network_instance in get_network_instances.items():
            assert helpers.test_model(models.network_instance, network_instance)
            assert helpers.test_model(models.network_instance_state, network_instance['state'])
            assert helpers.test_model(models.network_instance_interfaces,
                                      network_instance['interfaces'])

        return get_network_instances
Example #3
0
    def test_get_bgp_config(self, test_case):
        """Test get_bgp_config."""
        get_bgp_config = self.device.get_bgp_config()
        assert len(get_bgp_config) > 0

        for bgp_group in get_bgp_config.values():
            assert helpers.test_model(models.bgp_config_group, bgp_group)
            for bgp_neighbor in bgp_group.get('neighbors', {}).values():
                assert helpers.test_model(models.bgp_config_neighbor,
                                          bgp_neighbor)

        return get_bgp_config
    def test_get_snmp_information(self, test_case):
        """Test get_snmp_information."""
        get_snmp_information = self.device.get_snmp_information()

        assert len(get_snmp_information) > 0

        for snmp_entry in get_snmp_information:
            assert helpers.test_model(models.snmp, get_snmp_information)

        for community, community_data in get_snmp_information['community'].items():
            assert helpers.test_model(models.snmp_community, community_data)

        return get_snmp_information
    def test_ping(self, test_case):
        """Test ping."""
        destination = '8.8.8.8'
        get_ping = self.device.ping(destination)
        assert isinstance(get_ping.get('success'), dict)
        ping_results = get_ping.get('success', {})

        assert helpers.test_model(models.ping, ping_results)

        for ping_result in ping_results.get('results', []):
            assert helpers.test_model(models.ping_result, ping_result)

        return get_ping
Example #6
0
    def test_ping(self, test_case):
        """Test ping."""
        destination = '8.8.8.8'
        get_ping = self.device.ping(destination)
        assert isinstance(get_ping.get('success'), dict)
        ping_results = get_ping.get('success', {})

        assert helpers.test_model(models.ping, ping_results)

        for ping_result in ping_results.get('results', []):
            assert helpers.test_model(models.ping_result, ping_result)

        return get_ping
    def test_get_interfaces_ip(self, test_case):
        """Test get_interfaces_ip."""
        get_interfaces_ip = self.device.get_interfaces_ip()
        assert len(get_interfaces_ip) > 0

        for interface, interface_details in get_interfaces_ip.items():
            ipv4 = interface_details.get('ipv4', {})
            ipv6 = interface_details.get('ipv6', {})
            for ip, ip_details in ipv4.items():
                assert helpers.test_model(models.interfaces_ip, ip_details)
            for ip, ip_details in ipv6.items():
                assert helpers.test_model(models.interfaces_ip, ip_details)

        return get_interfaces_ip
Example #8
0
    def test_get_interfaces_ip(self, test_case):
        """Test get_interfaces_ip."""
        get_interfaces_ip = self.device.get_interfaces_ip()
        assert len(get_interfaces_ip) > 0

        for interface, interface_details in get_interfaces_ip.items():
            ipv4 = interface_details.get('ipv4', {})
            ipv6 = interface_details.get('ipv6', {})
            for ip, ip_details in ipv4.items():
                assert helpers.test_model(models.interfaces_ip, ip_details)
            for ip, ip_details in ipv6.items():
                assert helpers.test_model(models.interfaces_ip, ip_details)

        return get_interfaces_ip
Example #9
0
    def test_get_snmp_information(self, test_case):
        """Test get_snmp_information."""
        get_snmp_information = self.device.get_snmp_information()

        assert len(get_snmp_information) > 0

        for snmp_entry in get_snmp_information:
            assert helpers.test_model(models.snmp, get_snmp_information)

        for community, community_data in get_snmp_information[
                'community'].items():
            assert helpers.test_model(models.snmp_community, community_data)

        return get_snmp_information
Example #10
0
    def test_get_network_instances(self, test_case):
        """Test get_network_instances method."""
        get_network_instances = self.device.get_network_instances()

        assert isinstance(get_network_instances, dict)
        for network_instance_name, network_instance in get_network_instances:
            assert helpers.test_model(models.network_instance,
                                      network_instance)
            assert helpers.test_model(models.network_instance_state,
                                      network_instance['state'])
            assert helpers.test_model(models.network_instance_interfaces,
                                      network_instance['interfaces'])

        return get_network_instances
Example #11
0
    def test_get_bgp_neighbors(self, test_case):
        """Test get_bgp_neighbors."""
        get_bgp_neighbors = self.device.get_bgp_neighbors()
        assert 'global' in get_bgp_neighbors.keys()

        for vrf, vrf_data in get_bgp_neighbors.items():
            assert isinstance(vrf_data['router_id'], text_type)

            for peer, peer_data in vrf_data['peers'].items():
                assert helpers.test_model(models.peer, peer_data)

                for af, af_data in peer_data['address_family'].items():
                    assert helpers.test_model(models.af, af_data)

        return get_bgp_neighbors
Example #12
0
    def test_get_bgp_neighbors(self, test_case):
        """Test get_bgp_neighbors."""
        get_bgp_neighbors = self.device.get_bgp_neighbors()
        assert 'global' in get_bgp_neighbors.keys()

        for vrf, vrf_data in get_bgp_neighbors.items():
            assert isinstance(vrf_data['router_id'], text_type)

            for peer, peer_data in vrf_data['peers'].items():
                assert helpers.test_model(models.peer, peer_data)

                for af, af_data in peer_data['address_family'].items():
                    assert helpers.test_model(models.af, af_data)

        return get_bgp_neighbors
Example #13
0
    def test_get_config(self, test_case):
        """Test get_config method."""
        get_config = self.device.get_config()

        assert isinstance(get_config, dict)
        assert helpers.test_model(models.config, get_config)

        return get_config
Example #14
0
    def test_get_config(self, test_case):
        """Test get_config method."""
        get_config = self.device.get_config()

        assert isinstance(get_config, dict)
        assert helpers.test_model(models.config, get_config)

        return get_config
Example #15
0
 def test_get_firewall_policies(self, test_case):
     """Test get_firewall_policies method."""
     get_firewall_policies = self.device.get_firewall_policies()
     assert len(get_firewall_policies) > 0
     for policy_name, policy_details in get_firewall_policies.items():
         for policy_term in policy_details:
             assert helpers.test_model(models.firewall_policies, policy_term)
     return get_firewall_policies
Example #16
0
    def test_get_ntp_stats(self, test_case):
        """Test get_ntp_stats."""
        get_ntp_stats = self.device.get_ntp_stats()
        assert len(get_ntp_stats) > 0

        for ntp_peer_details in get_ntp_stats:
            assert helpers.test_model(models.ntp_stats, ntp_peer_details)

        return get_ntp_stats
Example #17
0
    def test_get_arp_table(self, test_case):
        """Test get_arp_table."""
        get_arp_table = self.device.get_arp_table()
        assert len(get_arp_table) > 0

        for arp_entry in get_arp_table:
            assert helpers.test_model(models.arp_table, arp_entry)

        return get_arp_table
Example #18
0
    def test_get_mac_address_table(self, test_case):
        """Test get_mac_address_table."""
        get_mac_address_table = self.device.get_mac_address_table()
        assert len(get_mac_address_table) > 0

        for mac_table_entry in get_mac_address_table:
            assert helpers.test_model(models.mac_address_table, mac_table_entry)

        return get_mac_address_table
Example #19
0
 def test_get_firewall_policies(self, test_case):
     """Test get_firewall_policies method."""
     get_firewall_policies = self.device.get_firewall_policies()
     assert len(get_firewall_policies) > 0
     for policy_name, policy_details in get_firewall_policies.items():
         for policy_term in policy_details:
             assert helpers.test_model(models.firewall_policies,
                                       policy_term)
     return get_firewall_policies
    def test_get_interfaces(self, test_case):
        """Test get_interfaces."""
        get_interfaces = self.device.get_interfaces()
        assert len(get_interfaces) > 0

        for interface, interface_data in get_interfaces.items():
            assert helpers.test_model(models.interface, interface_data)

        return get_interfaces
Example #21
0
    def test_get_ntp_stats(self, test_case):
        """Test get_ntp_stats."""
        get_ntp_stats = self.device.get_ntp_stats()
        assert len(get_ntp_stats) > 0

        for ntp_peer_details in get_ntp_stats:
            assert helpers.test_model(models.ntp_stats, ntp_peer_details)

        return get_ntp_stats
Example #22
0
    def test_get_interfaces(self, test_case):
        """Test get_interfaces."""
        get_interfaces = self.device.get_interfaces()
        assert len(get_interfaces) > 0

        for interface, interface_data in get_interfaces.items():
            assert helpers.test_model(models.interface, interface_data)

        return get_interfaces
Example #23
0
    def test_get_arp_table(self, test_case):
        """Test get_arp_table."""
        get_arp_table = self.device.get_arp_table()
        assert len(get_arp_table) > 0

        for arp_entry in get_arp_table:
            assert helpers.test_model(models.arp_table, arp_entry)

        return get_arp_table
Example #24
0
    def test_get_ntp_servers(self, test_case):
        """Test get_ntp_servers."""
        get_ntp_servers = self.device.get_ntp_servers()
        assert len(get_ntp_servers) > 0

        for server, server_details in get_ntp_servers.items():
            assert isinstance(server, text_type)
            assert helpers.test_model(models.ntp_server, server_details)

        return get_ntp_servers
Example #25
0
    def test_get_ntp_servers(self, test_case):
        """Test get_ntp_servers."""
        get_ntp_servers = self.device.get_ntp_servers()
        assert len(get_ntp_servers) > 0

        for server, server_details in get_ntp_servers.items():
            assert isinstance(server, text_type)
            assert helpers.test_model(models.ntp_server, server_details)

        return get_ntp_servers
Example #26
0
    def test_get_lldp_neighbors(self, test_case):
        """Test get_lldp_neighbors."""
        get_lldp_neighbors = self.device.get_lldp_neighbors()
        assert len(get_lldp_neighbors) > 0

        for interface, neighbor_list in get_lldp_neighbors.items():
            for neighbor in neighbor_list:
                assert helpers.test_model(models.lldp_neighbors, neighbor)

        return get_lldp_neighbors
Example #27
0
    def test_get_lldp_neighbors_detail(self, test_case):
        """Test get_lldp_neighbors_detail."""
        get_lldp_neighbors_detail = self.device.get_lldp_neighbors_detail()
        assert len(get_lldp_neighbors_detail) > 0

        for interface, neighbor_list in get_lldp_neighbors_detail.items():
            for neighbor in neighbor_list:
                assert helpers.test_model(models.lldp_neighbors_detail, neighbor)

        return get_lldp_neighbors_detail
Example #28
0
    def test_get_mac_address_table(self, test_case):
        """Test get_mac_address_table."""
        get_mac_address_table = self.device.get_mac_address_table()
        assert len(get_mac_address_table) > 0

        for mac_table_entry in get_mac_address_table:
            assert helpers.test_model(models.mac_address_table,
                                      mac_table_entry)

        return get_mac_address_table
Example #29
0
    def test_get_users(self, test_case):
        """Test get_users."""
        get_users = self.device.get_users()
        assert len(get_users)

        for user, user_details in get_users.items():
            assert helpers.test_model(models.users, user_details)
            assert (0 <= user_details.get('level') <= 15)

        return get_users
Example #30
0
    def test_get_probes_results(self, test_case):
        """Test get_probes_results."""
        get_probes_results = self.device.get_probes_results()
        assert len(get_probes_results) > 0

        for probe_name, probe_tests in get_probes_results.items():
            for test_name, test_results in probe_tests.items():
                assert helpers.test_model(models.probe_test_results, test_results)

        return get_probes_results
Example #31
0
    def test_get_users(self, test_case):
        """Test get_users."""
        get_users = self.device.get_users()
        assert len(get_users)

        for user, user_details in get_users.items():
            assert helpers.test_model(models.users, user_details)
            assert (0 <= user_details.get('level') <= 15)

        return get_users
Example #32
0
    def test_get_probes_config(self, test_case):
        """Test get_probes_config."""
        get_probes_config = self.device.get_probes_config()

        assert len(get_probes_config) > 0

        for probe_name, probe_tests in get_probes_config.items():
            for test_name, test_config in probe_tests.items():
                assert helpers.test_model(models.probe_test, test_config)

        return get_probes_config
Example #33
0
    def test_get_route_to(self, test_case):
        """Test get_route_to."""
        get_route_to = self.device.get_route_to()

        assert len(get_route_to) > 0

        for prefix, routes in get_route_to.items():
            for route in routes:
                assert helpers.test_model(models.route, route)

        return get_route_to
Example #34
0
    def test_get_probes_config(self, test_case):
        """Test get_probes_config."""
        get_probes_config = self.device.get_probes_config()

        assert len(get_probes_config) > 0

        for probe_name, probe_tests in get_probes_config.items():
            for test_name, test_config in probe_tests.items():
                assert helpers.test_model(models.probe_test, test_config)

        return get_probes_config
Example #35
0
    def test_get_probes_results(self, test_case):
        """Test get_probes_results."""
        get_probes_results = self.device.get_probes_results()
        assert len(get_probes_results) > 0

        for probe_name, probe_tests in get_probes_results.items():
            for test_name, test_results in probe_tests.items():
                assert helpers.test_model(models.probe_test_results,
                                          test_results)

        return get_probes_results
Example #36
0
    def test_get_environment(self, test_case):
        """Test get_environment."""
        environment = self.device.get_environment()
        assert len(environment) > 0

        for fan, fan_data in environment['fans'].items():
            assert helpers.test_model(models.fan, fan_data)

        for power, power_data in environment['power'].items():
            assert helpers.test_model(models.power, power_data)

        for temperature, temperature_data in environment['temperature'].items():
            assert helpers.test_model(models.temperature, temperature_data)

        for cpu, cpu_data in environment['cpu'].items():
            assert helpers.test_model(models.cpu, cpu_data)

        assert helpers.test_model(models.memory, environment['memory'])

        return environment
Example #37
0
    def test_traceroute(self, test_case):
        """Test traceroute."""
        destination = '8.8.8.8'
        get_traceroute = self.device.traceroute(destination)
        assert isinstance(get_traceroute.get('success'), dict)
        traceroute_results = get_traceroute.get('success', {})

        for hope_id, hop_result in traceroute_results.items():
            for probe_id, probe_result in hop_result.get('probes', {}).items():
                assert helpers.test_model(models.traceroute, probe_result)

        return get_traceroute
Example #38
0
    def test_traceroute(self, test_case):
        """Test traceroute."""
        destination = '8.8.8.8'
        get_traceroute = self.device.traceroute(destination)
        assert isinstance(get_traceroute.get('success'), dict)
        traceroute_results = get_traceroute.get('success', {})

        for hope_id, hop_result in traceroute_results.items():
            for probe_id, probe_result in hop_result.get('probes', {}).items():
                assert helpers.test_model(models.traceroute, probe_result)

        return get_traceroute
Example #39
0
    def test_get_environment(self, test_case):
        """Test get_environment."""
        environment = self.device.get_environment()
        assert len(environment) > 0

        for fan, fan_data in environment['fans'].items():
            assert helpers.test_model(models.fan, fan_data)

        for power, power_data in environment['power'].items():
            assert helpers.test_model(models.power, power_data)

        for temperature, temperature_data in environment['temperature'].items(
        ):
            assert helpers.test_model(models.temperature, temperature_data)

        for cpu, cpu_data in environment['cpu'].items():
            assert helpers.test_model(models.cpu, cpu_data)

        assert helpers.test_model(models.memory, environment['memory'])

        return environment
Example #40
0
    def test_get_route_to(self, test_case):
        """Test get_route_to."""
        destination = '1.0.4.0/24'
        protocol = 'bgp'
        get_route_to = self.device.get_route_to(destination=destination, protocol=protocol)

        assert len(get_route_to) > 0

        for prefix, routes in get_route_to.items():
            for route in routes:
                assert helpers.test_model(models.route, route)

        return get_route_to
Example #41
0
    def test_get_route_to(self, test_case):
        """Test get_route_to."""
        destination = '1.0.4.0/24'
        protocol = 'bgp'
        get_route_to = self.device.get_route_to(destination=destination,
                                                protocol=protocol)

        assert len(get_route_to) > 0

        for prefix, routes in get_route_to.items():
            for route in routes:
                assert helpers.test_model(models.route, route)

        return get_route_to
Example #42
0
    def test_get_bgp_neighbors_detail(self, test_case):
        """Test get_bgp_neighbors_detail."""
        get_bgp_neighbors_detail = self.device.get_bgp_neighbors_detail()

        assert len(get_bgp_neighbors_detail) > 0

        for vrf, vrf_ases in get_bgp_neighbors_detail.items():
            assert isinstance(vrf, text_type)
            for remote_as, neighbor_list in vrf_ases.items():
                assert isinstance(remote_as, int)
                for neighbor in neighbor_list:
                    assert helpers.test_model(models.peer_details, neighbor)

        return get_bgp_neighbors_detail
Example #43
0
    def test_get_bgp_neighbors_detail(self, test_case):
        """Test get_bgp_neighbors_detail."""
        get_bgp_neighbors_detail = self.device.get_bgp_neighbors_detail()

        assert len(get_bgp_neighbors_detail) > 0

        for vrf, vrf_ases in get_bgp_neighbors_detail.items():
            assert isinstance(vrf, text_type)
            for remote_as, neighbor_list in vrf_ases.items():
                assert isinstance(remote_as, int)
                for neighbor in neighbor_list:
                    assert helpers.test_model(models.peer_details, neighbor)

        return get_bgp_neighbors_detail
Example #44
0
 def test_is_alive(self, test_case):
     """Test is_alive method."""
     alive = self.device.is_alive()
     assert helpers.test_model(models.alive, alive)
     return alive
Example #45
0
 def test_get_facts(self, test_case):
     """Test get_facts method."""
     facts = self.device.get_facts()
     assert helpers.test_model(models.facts, facts)
     return facts
Example #46
0
 def test_is_alive(self, test_case):
     """Test is_alive method."""
     alive = self.device.is_alive()
     assert helpers.test_model(models.alive, alive)
     return alive
Example #47
0
 def test_get_facts(self, test_case):
     """Test get_facts method."""
     facts = self.device.get_facts()
     assert helpers.test_model(models.facts, facts)
     return facts