Exemplo n.º 1
0
def test_query_with_branch_id_parameter(mq_create_three_specific_hosts,
                                        api_get, subtests):
    created_hosts = mq_create_three_specific_hosts
    # branch_id parameter is accepted, but doesn’t affect results.
    url = build_hosts_url(host_list_or_id=created_hosts,
                          query="?branch_id=123")
    api_query_test(api_get, subtests, url, created_hosts)
def test_query_existent_hosts(mq_create_three_specific_hosts, api_get, subtests):
    created_hosts = mq_create_three_specific_hosts
    host_lists = [created_hosts[0:1], created_hosts[1:3], created_hosts]

    for host_list in host_lists:
        with subtests.test(host_list=host_list):
            url = build_hosts_url(host_list_or_id=host_list)
            api_query_test(api_get, subtests, url, host_list)
def test_query_multiple_hosts_with_some_non_existent(mq_create_three_specific_hosts, api_get, subtests):
    created_hosts = mq_create_three_specific_hosts
    host_list = created_hosts[0:1]

    existent_host_id_list = build_host_id_list_for_url(host_list)
    non_existent_host_id = generate_uuid()

    url = build_hosts_url(host_list_or_id=f"{non_existent_host_id},{existent_host_id_list}")
    api_query_test(api_get, subtests, url, host_list)
def test_query_host_id_without_hyphens(mq_create_three_specific_hosts, api_get, subtests):
    created_hosts = mq_create_three_specific_hosts
    host_lists = [created_hosts[0:1], created_hosts]

    for original_host_list in host_lists:
        with subtests.test(host_list=original_host_list):
            # deepcopy host.__data to insulate original_host_list from changes.
            host_data = (host.data() for host in original_host_list)
            host_data = (copy.deepcopy(host) for host in host_data)
            query_host_list = [HostWrapper(host) for host in host_data]

            # Remove the hyphens from one of the valid hosts.
            query_host_list[0].id = uuid.UUID(query_host_list[0].id, version=4).hex

            url = build_hosts_url(host_list_or_id=query_host_list)
            api_query_test(api_get, subtests, url, original_host_list)
def test_query_single_non_existent_host(api_get, subtests):
    url = build_hosts_url(host_list_or_id=generate_uuid())
    api_query_test(api_get, subtests, url, [])