Skip to content

Commit

Permalink
Validator transfer p3 (#745)
Browse files Browse the repository at this point in the history
* Move validate_transaction_metrics to validators directory

* Comment out original validate_transaction_metrics from fixtures.py

* Move validate_time_metrics_outside_transaction to validators directory

* Move validate_internal_metrics into validators directory and fixed validate_transaction_metrics

* Move validate_transaction_errors into validators directory

* Move validate_application_errors into validators directory

* Move validate_custom_parameters into validators directory

* Move validate_synthetics_event into validators directory

* Move validate_transaction_event_attributes into validators directory

* Move validate_non_transaction_error_event into validators directory

* Move validate_application_error_trace_count into validators directory

* Move validate_application_error_event_count into validators directory

* Move validate_synthetics_transaction_trace into validators directory

* Move validate_tt_collector_json to validators directory

* Move validate_transaction_trace_attributes into validator directory

* Move validate_transaction_error_trace_attributes into validator directory

* Move validate_error_trace_collector_json into validator directory

* Move validate_error_event_collector_json into validator directory

* Move validate_transaction_event_collector_json into validator directory

* Move validate_custom_event_collector_json into validator directory

* Move validate_tt_parameters into validator directory

* Move validate_tt_parameters into validator directory

* Move validate_tt_segment_params into validator directory

* Move validate_browser_attributes into validators directory

* Move validate_error_event_attributes into validators directory

* Move validate_error_trace_attributes_outside_transaction into validators directory

* Move validate_error_event_attributes_outside_transaction into validators directory

* Fix some pylint errors

* Redirect check_error_attributes

* Fix more Pylint errors

* Fix import issues from move

* Fix more import shuffle errors

* Sort logging JSON test for PY2 consistency

* Fix Pylint errors in validators

* Fix import error

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
lrafeei and mergify[bot] authored Jun 14, 2023
1 parent 3def8b0 commit 90ccb4c
Show file tree
Hide file tree
Showing 30 changed files with 1,237 additions and 1,041 deletions.
2 changes: 1 addition & 1 deletion tests/agent_features/test_asgi_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_footer_attributes():

obfuscation_key = settings.license_key[:13]

type_transaction_data = unicode if six.PY2 else str # noqa: F821
type_transaction_data = unicode if six.PY2 else str # noqa: F821, pylint: disable=E0602
assert isinstance(data["transactionName"], type_transaction_data)

txn_name = deobfuscate(data["transactionName"], obfuscation_key)
Expand Down
29 changes: 22 additions & 7 deletions tests/agent_features/test_attributes_in_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@
override_application_settings,
reset_core_stats_engine,
validate_attributes,
)
from testing_support.validators.validate_browser_attributes import (
validate_browser_attributes,
)
from testing_support.validators.validate_error_event_attributes import (
validate_error_event_attributes,
)
from testing_support.validators.validate_error_event_attributes_outside_transaction import (
validate_error_event_attributes_outside_transaction,
validate_error_trace_attributes_outside_transaction,
)
from testing_support.validators.validate_error_trace_attributes import (
validate_error_trace_attributes,
)
from testing_support.validators.validate_error_trace_attributes_outside_transaction import (
validate_error_trace_attributes_outside_transaction,
)
from testing_support.validators.validate_span_events import validate_span_events
from testing_support.validators.validate_transaction_error_trace_attributes import (
validate_transaction_error_trace_attributes,
Expand All @@ -43,7 +51,7 @@
from newrelic.api.background_task import background_task
from newrelic.api.message_transaction import message_transaction
from newrelic.api.time_trace import notice_error
from newrelic.api.transaction import add_custom_attribute, current_transaction, set_user_id
from newrelic.api.transaction import add_custom_attribute, set_user_id
from newrelic.api.wsgi_application import wsgi_application
from newrelic.common.object_names import callable_name

Expand Down Expand Up @@ -930,16 +938,21 @@ def test_none_type_routing_key_agent_attribute():
_forgone_agent_attributes = []


@pytest.mark.parametrize('input_user_id, reported_user_id, high_security',(
@pytest.mark.parametrize(
"input_user_id, reported_user_id, high_security",
(
("1234", "1234", True),
("a" * 260, "a" * 255, False),
))
("a" * 260, "a" * 255, False),
),
)
def test_enduser_id_attribute_api_valid_types(input_user_id, reported_user_id, high_security):
@reset_core_stats_engine()
@validate_error_trace_attributes(
callable_name(ValueError), exact_attrs={"user": {}, "intrinsic": {}, "agent": {"enduser.id": reported_user_id}}
)
@validate_error_event_attributes(exact_attrs={"user": {}, "intrinsic": {}, "agent": {"enduser.id": reported_user_id}})
@validate_error_event_attributes(
exact_attrs={"user": {}, "intrinsic": {}, "agent": {"enduser.id": reported_user_id}}
)
@validate_attributes("agent", _required_agent_attributes, _forgone_agent_attributes)
@background_task()
@override_application_settings({"high_security": high_security})
Expand All @@ -950,10 +963,11 @@ def _test():
raise ValueError()
except Exception:
notice_error()

_test()


@pytest.mark.parametrize('input_user_id',(None, '', 123))
@pytest.mark.parametrize("input_user_id", (None, "", 123))
def test_enduser_id_attribute_api_invalid_types(input_user_id):
@reset_core_stats_engine()
@validate_attributes("agent", [], ["enduser.id"])
Expand All @@ -965,4 +979,5 @@ def _test():
raise ValueError()
except Exception:
notice_error()

_test()
8 changes: 4 additions & 4 deletions tests/agent_features/test_collector_payloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

import pytest
import webtest
from testing_support.fixtures import (
override_application_settings,
validate_custom_event_collector_json,
)
from testing_support.fixtures import override_application_settings
from testing_support.sample_applications import (
simple_app,
simple_custom_event_app,
simple_exceptional_app,
)
from testing_support.validators.validate_custom_event_collector_json import (
validate_custom_event_collector_json,
)
from testing_support.validators.validate_error_event_collector_json import (
validate_error_event_collector_json,
)
Expand Down
Loading

0 comments on commit 90ccb4c

Please sign in to comment.