Esempio n. 1
0
def test_get_ping_properties_keyedHistogram(test_store, dummy_pool_executor,
                                            mock_message_parser,
                                            spark_context):
    ping = {
        "payload": {
            "keyedHistograms": {
                "TEST": {
                    "key1": {
                        "values": {
                            "0": 1
                        }
                    },
                    "key2": {
                        "values": {
                            "0": 2
                        }
                    },
                },
            }
        }
    }

    field = 'payload/keyedHistograms/TEST'

    props = _get_ping_properties(ping, [(field, field.split("/"))],
                                 only_median=False,
                                 with_processes=False,
                                 histograms_url=None,
                                 additional_histograms=additional_histograms)

    # assert the values
    hist = props[field]
    assert set(hist.keys()) == set(['key1', 'key2'])
    assert hist['key1'] == 1
    assert hist['key2'] == 2
Esempio n. 2
0
def test_get_ping_properties_scalar(test_store, dummy_pool_executor,
                                    mock_message_parser, spark_context):
    ping = {
        "payload": {
            "processes": {
                "parent": {
                    "scalars": {
                        "bool_false": False,
                        "bool_true": True
                    },
                },
            }
        }
    }

    scalars = 'payload/processes/parent/scalars'
    bool_false = scalars + '/bool_false'
    bool_true = scalars + '/bool_true'
    bool_missing = scalars + '/bool_missing'

    paths = [(path, path.split("/"))
             for path in [bool_false, bool_true, bool_missing]]
    props = _get_ping_properties(ping,
                                 paths,
                                 only_median=False,
                                 with_processes=False,
                                 histograms_url=None,
                                 additional_histograms=additional_histograms)

    # assert the values
    assert props[bool_false] is False
    assert props[bool_true] is True
    assert props[bool_missing] is None