コード例 #1
0
ファイル: test_pings.py プロジェクト: rfk/glean_parser
def test_snake_case_ping_names():
    content = {"camelCasePingName": {"include_client_id": True}}

    util.add_required_ping(content)
    errors = list(parser.parse_objects([content]))
    assert len(errors) == 1
    assert "camelCasePingName" in errors[0]
コード例 #2
0
ファイル: test_pings.py プロジェクト: rfk/glean_parser
def test_reserved_ping_name():
    """
    Make sure external users can't use a reserved ping name.
    """
    content = {"baseline": {"include_client_id": True}}

    util.add_required_ping(content)
    errors = list(parser._instantiate_pings({}, {}, content, "", {}))
    assert len(errors) == 1
    assert "Ping uses a reserved name" in errors[0]

    errors = list(
        parser._instantiate_pings({}, {}, content, "",
                                  {"allow_reserved": True}))
    assert len(errors) == 0
コード例 #3
0
def test_all_pings_reserved():
    # send_in_pings: [all_pings] is only allowed for internal metrics
    contents = [{
        "category": {
            "metric": {
                "type": "string",
                "send_in_pings": ["all_pings"]
            }
        }
    }]

    contents = [util.add_required(x) for x in contents]
    all_metrics = parser.parse_objects(contents)
    errors = list(all_metrics)
    assert len(errors) == 1
    assert "On instance category.metric" in errors[0]
    assert "Only internal metrics" in errors[0]

    all_metrics = parser.parse_objects(contents, {"allow_reserved": True})
    errors = list(all_metrics)
    assert len(errors) == 0

    # A custom ping called "all_pings" is not allowed
    contents = [{"all_pings": {"include_client_id": True}}]
    contents = [util.add_required_ping(x) for x in contents]
    all_pings = parser.parse_objects(contents)
    errors = list(all_pings)
    assert len(errors) == 1
    assert "is not allowed for 'all_pings'"
コード例 #4
0
def test_send_if_empty():
    content = {"valid-ping": {"include_client_id": True, "send_if_empty": True}}

    util.add_required_ping(content)
    errors = list(parser.parse_objects([content]))
    assert len(errors) == 0
コード例 #5
0
def test_legacy_snake_case_ping_name():
    content = {"bookmarks_sync": {"include_client_id": True}}

    util.add_required_ping(content)
    errors = list(parser.parse_objects([content]))
    assert len(errors) == 0