def assert_host_exists_in_db(host_id,
                             search_canonical_facts,
                             account=USER_IDENTITY):
    identity = Identity(account)
    found_host = find_existing_host(identity, search_canonical_facts)

    assert host_id == found_host.id
示例#2
0
def host_checkin(body):
    canonical_facts = deserialize_canonical_facts(body)
    existing_host = find_existing_host(current_identity.account_number, canonical_facts)

    if existing_host:
        existing_host._update_modified_date()
        db.session.commit()
        serialized_host = serialize_host(existing_host, staleness_timestamps(), EGRESS_HOST_FIELDS)
        _emit_patch_event(serialized_host, existing_host.id, existing_host.canonical_facts.get("insights_id"))
        return flask_json_response(serialized_host, 201)
    else:
        flask.abort(404, "No hosts match the provided canonical facts.")
def test_find_host_using_elevated_ids_match(flask_app_fixture,
                                            host_create_order, expected_host):
    hosts_canonical_facts = ({
        "subscription_manager_id": generate_uuid()
    }, {
        "insights_id": generate_uuid()
    })

    created_hosts = []
    for host_canonical_facts in host_create_order:
        created_host = create_host(hosts_canonical_facts[host_canonical_facts])
        created_hosts.append(created_host)

    search_canonical_facts = {
        key: value
        for host_canonical_facts in hosts_canonical_facts
        for key, value in host_canonical_facts.items()
    }
    found_host = find_existing_host(ACCOUNT_NUMBER, search_canonical_facts)

    assert created_hosts[expected_host].id == found_host.id
def assert_host_exists_in_db(host_id, search_canonical_facts, account=ACCOUNT):
    found_host = find_existing_host(account, search_canonical_facts)

    assert host_id == found_host.id
def basic_host_dedup_test(initial_canonical_facts, search_canonical_facts):
    original_host = create_host(initial_canonical_facts)

    found_host = find_existing_host(ACCOUNT_NUMBER, search_canonical_facts)

    assert original_host.id == found_host.id
def assert_host_missing_from_db(search_canonical_facts,
                                identity=USER_IDENTITY):
    identity = Identity(identity)
    assert not find_existing_host(identity, search_canonical_facts)