def test_flush_queued_events_on_startup(safe_httpserver): safe_httpserver.serve_content(b"", code=200) Glean._configuration.server_endpoint = safe_httpserver.url class EventKeys(enum.Enum): SOME_EXTRA = 0 event = metrics.EventMetricType( disabled=False, category="telemetry", lifetime=Lifetime.PING, name="test_event", send_in_pings=["events"], allowed_extra_keys=["some_extra"], ) event.record(extra={EventKeys.SOME_EXTRA: "bar"}) assert 1 == len(event.test_get_value()) testing.reset_glean( application_id="glean-python-test", application_version=glean_version, clear_stores=False, configuration=Configuration(server_endpoint=safe_httpserver.url), ) assert 1 == len(safe_httpserver.requests) request = safe_httpserver.requests[0] assert "events" in request.url
def test_flush_queued_events_on_startup_and_correctly_handle_preinit_events( safe_httpserver, ): safe_httpserver.serve_content(b"", code=200) Glean._configuration.server_endpoint = safe_httpserver.url Glean._configuration.log_pings = True class EventKeys(enum.Enum): SOME_EXTRA = 0 event = metrics.EventMetricType( disabled=False, category="telemetry", lifetime=Lifetime.PING, name="test_event", send_in_pings=["events"], allowed_extra_keys=["some_extra"], ) event.record(extra={EventKeys.SOME_EXTRA: "run1"}) assert 1 == len(event.test_get_value()) Dispatcher.set_task_queueing(True) event.record(extra={EventKeys.SOME_EXTRA: "pre-init"}) testing.reset_glean( application_id="glean-python-test", application_version=glean_version, clear_stores=False, configuration=Configuration(server_endpoint=safe_httpserver.url, log_pings=True), ) event.record(extra={EventKeys.SOME_EXTRA: "post-init"}) assert 1 == len(safe_httpserver.requests) request = safe_httpserver.requests[0] assert "events" in request.url assert 1 == len(event.test_get_value()) Glean._submit_ping_by_name("events") assert 2 == len(safe_httpserver.requests) request = safe_httpserver.requests[1] assert "events" in request.url
def pytest_runtest_setup(item): testing.reset_glean(application_id="glean-python-test", application_version=glean_version)
def fixture_reset_glean(): testing.reset_glean(application_id="mozphab", application_version="0.1.86")
def fixture_reset_glean(): """Reset the Glean SDK before every test.""" testing.reset_glean(application_id="burnham_testing", application_version="0.1.0")