def test_setting_a_url_as_none(): url_metric = metrics.UrlMetricType( disabled=False, category="telemetry", lifetime=Lifetime.APPLICATION, name="url_metric", send_in_pings=["store1", "store2"], ) url_metric.set(None) assert not url_metric.test_has_value()
def test_disabled_urls_must_not_record_data(): url_metric = metrics.UrlMetricType( disabled=True, category="telemetry", lifetime=Lifetime.APPLICATION, name="url_metric", send_in_pings=["store1"], ) url_metric.set("glean://testing") assert not url_metric.test_has_value()
def test_setting_a_long_url_records_an_error(): url_metric = metrics.UrlMetricType( disabled=False, category="telemetry", lifetime=Lifetime.APPLICATION, name="url_metric", send_in_pings=["store1", "store2"], ) url_metric.set("glean://" + "testing" * 2000) assert 1 == url_metric.test_get_num_recorded_errors( testing.ErrorType.INVALID_OVERFLOW)
def test_the_api_saves_to_its_storage_engine(): url_metric = metrics.UrlMetricType( disabled=False, category="telemetry", lifetime=Lifetime.APPLICATION, name="url_metric", send_in_pings=["store1"], ) url_metric.set("glean://testing") assert url_metric.test_has_value() assert "glean://testing" == url_metric.test_get_value() url_metric.set("glean://overriddenValue") assert url_metric.test_has_value() assert "glean://overriddenValue" == url_metric.test_get_value()
def test_the_api_saves_to_secondary_pings(): url_metric = metrics.UrlMetricType( disabled=False, category="telemetry", lifetime=Lifetime.APPLICATION, name="url_metric", send_in_pings=["store1", "store2"], ) url_metric.set("glean://value") assert url_metric.test_has_value("store2") assert "glean://value" == url_metric.test_get_value("store2") url_metric.set("glean://overriddenValue") assert url_metric.test_has_value("store2") assert "glean://overriddenValue" == url_metric.test_get_value("store2")