示例#1
0
def test_parse_ep_data(data, get_ep_data, expected):
    def dummy_parse_and_return_ep_data(self, ep_data):
        return get_data(get_ep_data)

    AciUtils.parse_and_return_ep_data = dummy_parse_and_return_ep_data

    obj = AciUtils()
    response = obj.parse_ep_data(get_data(data))

    assert response == get_data(expected)
示例#2
0
def test_get_interface(data, node, expected):

    # Mock apic_util get_node_from_interface
    def dummy_get_node_from_interface(self, interface):
        return get_data(node)

    AciUtils.get_node_from_interface = dummy_get_node_from_interface

    # Test the function
    obj = AciUtils()
    response = obj.get_interface(get_data(data))

    assert response == get_data(expected)
示例#3
0
def test_parse_and_return_ep_data(data, ep_data, expected):

    # Mock AciUtils functions
    def dummy_get_ep_info(self, ep_attr):
        return get_data(ep_data)

    def dummy_get_ip_mac_list(ep_child):
        return [[get_data("data/ip_2.json"), True],
                [get_data("data/ip_1.json"), False]]

    AciUtils.get_ep_info = dummy_get_ep_info

    # Test the function
    obj = AciUtils()
    response = obj.parse_and_return_ep_data(get_data(data))

    assert response == get_data(expected)
示例#4
0
def test_get_controller_and_hosting_server(data, mo_instance_data, expected):
    def dummy_get_all_mo_instances(self, mo_class, query_string=""):
        return get_data(mo_instance_data)

    AciUtils.get_all_mo_instances = dummy_get_all_mo_instances

    # Test the function
    obj = AciUtils()
    response = obj.get_controller_and_hosting_server(get_data(data))

    assert response == expected
示例#5
0
def test_get_all_mo_instances(data, expected):
    def dummy_aci_get(self, url):
        return get_data(data)

    AciUtils.aci_get = dummy_aci_get

    # Test the function
    obj = AciUtils()
    response = obj.get_all_mo_instances("dummy-class", "dummy-query")

    assert response == get_data(expected)
示例#6
0
def test_get_vm_domain_and_name(aci_get_data, data):
    """Test the VM Domain and Name"""
    def dummy_aci_get(self, url):
        return get_data(aci_get_data)

    AciUtils.aci_get = dummy_aci_get

    # Test the function
    obj = AciUtils()
    response = obj.get_vm_domain_and_name(get_data(data))

    assert response == ('DUMMY0-leaf000', 'dummy-vm-name')
示例#7
0
def test_get_ep_info(data, expected):

    # Mock AciUtils functions
    def dummy_get_controller_and_hosting_server(self, ep_child):
        return ("hyper000", get_data("data/ip_1.json"))

    def dummy_get_interface(self, ep_child):
        return "Pod-0/Node-111/eth0/0"

    def dummy_get_vm_domain_and_name(self, ep_child):
        return ('DUMMY0-leaf000', 'dummy-vm-name')

    AciUtils.get_controller_and_hosting_server = dummy_get_controller_and_hosting_server
    AciUtils.get_interface = dummy_get_interface
    AciUtils.get_vm_domain_and_name = dummy_get_vm_domain_and_name

    # Test the function
    obj = AciUtils()
    response = obj.get_ep_info(get_data(data))

    assert response == get_data(expected)
示例#8
0
def test_get_epg_health(data, dn, expected):
    # Mock AciUtils methods
    def dummy_aci_get(self, url):
        return get_data(data)

    AciUtils.aci_get = dummy_aci_get
    AciUtils.proto = "http://"
    AciUtils.apic_ip = "dummy-apic-ip"

    obj = AciUtils()
    response = obj.get_epg_health(dn)

    assert response == get_data(expected)
示例#9
0
def test_apic_fetch_vrf_tenant(data, tn, expected):

    # Mock AciUtils methods
    def dummy_aci_get(self, url):
        return get_data(data)

    AciUtils.aci_get = dummy_aci_get
    AciUtils.proto = "http://"
    AciUtils.apic_ip = "dummy-apic-ip"

    obj = AciUtils()
    response = obj.apic_fetch_vrf_tenant(tn)

    assert response == get_data(expected)
示例#10
0
def test_parse_and_return_epg_data(data, contract, expected):

    # Mock AciUtils methods
    def dummy_apic_fetch_bd(self, url):
        return "Dummy-BD0"

    def dummy_apic_fetch_vrf(self, url):
        return "Dummy-VRF"

    def dummy_apic_fetch_contract(self, url):
        return get_data(contract)

    def dummy_get_epg_health(self, url):
        return "96"

    AciUtils.apic_fetch_bd = dummy_apic_fetch_bd
    AciUtils.apic_fetch_vrf = dummy_apic_fetch_vrf
    AciUtils.apic_fetch_contract = dummy_apic_fetch_contract
    AciUtils.get_epg_health = dummy_get_epg_health

    obj = AciUtils()
    response = obj.parse_and_return_epg_data(get_data(data))

    assert response == get_data(expected)
示例#11
0
 def dummy_aci_get(self, url):
     return get_data(aci_get_data)
示例#12
0
 def dummy_parse_and_return_ep_data(self, ep_data):
     return get_data(get_ep_data)
示例#13
0
 def dummy_get_ep_info(self, ep_attr):
     return get_data(ep_data)
示例#14
0
 def dummy_get_controller_and_hosting_server(self, ep_child):
     return ("hyper000", get_data("data/ip_1.json"))
示例#15
0
def test_get_ip_mac_list(data, expected):

    response = AciUtils.get_ip_mac_list(get_data(data))

    assert response == get_data(expected)
示例#16
0
 def dummy_get_all_mo_instances(self, mo_class, query_string=""):
     return get_data(mo_instance_data)
示例#17
0
 def dummy_apic_fetch_contract(self, url):
     return get_data(contract)
示例#18
0
 def dummy_get_ip_mac_list(ep_child):
     return [[get_data("data/ip_2.json"), True],
             [get_data("data/ip_1.json"), False]]
示例#19
0
 def dummy_get_node_from_interface(self, interface):
     return get_data(node)
示例#20
0
    def dummy_get_node_from_interface(self, interface):
        return get_data(node)

    AciUtils.get_node_from_interface = dummy_get_node_from_interface

    # Test the function
    obj = AciUtils()
    response = obj.get_interface(get_data(data))

    assert response == get_data(expected)


@pytest.mark.parametrize("data,mo_instance_data,expected", [
    ("data/get_controller_and_hosting_server/with_ip_host_input.json",
     "data/get_controller_and_hosting_server/with_ip_host_mo_instance.json",
     ('hyper000', get_data("data/ip_1.json"))),
    ("data/get_controller_and_hosting_server/with_host_input.json",
     "data/get_controller_and_hosting_server/with_host_mo_instance.json",
     ('hyper000', '')),
    ("data/get_controller_and_hosting_server/without_ip_host_input.json",
     "data/get_controller_and_hosting_server/without_ip_host_mo_instance.json",
     ('', ''))
])
def test_get_controller_and_hosting_server(data, mo_instance_data, expected):
    def dummy_get_all_mo_instances(self, mo_class, query_string=""):
        return get_data(mo_instance_data)

    AciUtils.get_all_mo_instances = dummy_get_all_mo_instances

    # Test the function
    obj = AciUtils()