Ejemplo n.º 1
0
def test_notes(row_to_dict, spark_context):
    input_payload = {
        'study': '@shield-study-privacy',
        'branch': 'thirdPartyCookiesOnlyFromVisited',
        'originDomain': 'www.paypal.com',
        'event': 'notes',
        'breakage': 'other',
        'notes': 'Paypal prompted me for Reader Mode. WTF?',
        'study_version': '0.0.1',
        'about': {
            '_src': 'addon',
            '_v': 2
        }
    }

    result_payload = input_payload

    actual = transform_event_pings(
        SQLContext(spark_context), create_ping_rdd(spark_context,
                                                   input_payload)).take(1)[0]

    assert row_to_dict(actual) == create_row(result_payload)
def test_page_breakage(row_to_dict, spark_context):
    input_payload = {
        "study": "@shield-study-privacy",
        "branch": "thirdPartyCookiesOnlyFromVisited",
        "originDomain": "www.paypal.com",
        "event": "breakage",
        "breakage": "other",
        "notes": None,
        "study_version": "0.0.1",
        "about": {
            "_src": "addon",
            "_v": 2
        },
    }

    result_payload = input_payload

    actual = transform_event_pings(
        SQLContext(spark_context), create_ping_rdd(spark_context,
                                                   input_payload)).take(1)[0]

    assert row_to_dict(actual) == create_row(result_payload)
def test_combine_state_and_event(row_to_dict, spark_context):
    state_payload = {
        "study_name": "@shield-study-privacy",
        "branch": "firstPartyIsolationOpenerAccess",
        "study_state": "running",
        "study_version": "0.0.4",
        "about": {
            "_src": "shield",
            "_v": 2
        },
    }
    event_payload = {
        "study": "@shield-study-privacy",
        "branch": "thirdPartyCookiesOnlyFromVisited",
        "originDomain": "www.paypal.com",
        "event": "disable",
        "breakage": None,
        "notes": None,
        "study_version": "0.0.4",
        "about": {
            "_src": "addon",
            "_v": 2
        },
    }
    transformed_event_ping = transform_event_pings(
        SQLContext(spark_context), create_ping_rdd(spark_context,
                                                   event_payload))
    transformed_state_ping = transform_state_pings(
        SQLContext(spark_context), create_ping_rdd(spark_context,
                                                   state_payload))

    transformed_pings = transformed_event_ping.union(transformed_state_ping)

    actual_rows = transformed_pings.take(2)

    for actual_row in actual_rows:
        assert row_to_dict(actual_row) == create_row(
            state_payload) or row_to_dict(actual_row) == create_row(
                event_payload)
Ejemplo n.º 4
0
def test_combine_state_and_event(row_to_dict, spark_context):
    state_payload = {
        "study_name": "@shield-study-privacy",
        "branch": "firstPartyIsolationOpenerAccess",
        "study_state": "running",
        "study_version": "0.0.4",
        "about": {
            "_src": "shield",
            "_v": 2
        }
    }
    event_payload = {
        'study': '@shield-study-privacy',
        'branch': 'thirdPartyCookiesOnlyFromVisited',
        'originDomain': 'www.paypal.com',
        'event': 'disable',
        'breakage': None,
        'notes': None,
        'study_version': '0.0.4',
        'about': {
            '_src': 'addon',
            '_v': 2
        }
    }
    transformed_event_ping = transform_event_pings(
        SQLContext(spark_context), create_ping_rdd(spark_context,
                                                   event_payload))
    transformed_state_ping = transform_state_pings(
        SQLContext(spark_context), create_ping_rdd(spark_context,
                                                   state_payload))

    transformed_pings = transformed_event_ping.union(transformed_state_ping)

    actual_rows = transformed_pings.take(2)

    for actual_row in actual_rows:
        assert (row_to_dict(actual_row) == create_row(state_payload)
                or row_to_dict(actual_row) == create_row(event_payload))