def test_timespan_time_unit(): """ Test that the timespan's time_unit is coerced to an enum. """ m = metrics.Timespan( type='timespan', category='category', name='metric', bugs=[42], time_unit='day', notification_emails=['*****@*****.**'], description='description...', ) assert isinstance(m.time_unit, metrics.TimeUnit) assert m.time_unit == metrics.TimeUnit.day with pytest.raises(AttributeError): m = metrics.Timespan( type='timespan', category='category', name='metric', bugs=[42], time_unit='foo', notification_emails=['*****@*****.**'], description='description...', )
def test_timespan_time_unit(): """ Test that the timespan's time_unit is coerced to an enum. """ m = metrics.Timespan( type="timespan", category="category", name="metric", bugs=[42], time_unit="day", notification_emails=["*****@*****.**"], description="description...", expires="never", ) assert isinstance(m.time_unit, metrics.TimeUnit) assert m.time_unit == metrics.TimeUnit.day with pytest.raises(AttributeError): m = metrics.Timespan( type="timespan", category="category", name="metric", bugs=[42], time_unit="foo", notification_emails=["*****@*****.**"], description="description...", expires="never", )
def test_extra_info_generator(): event = metrics.Event( type="event", category="category", name="metric", bugs=[42], notification_emails=["*****@*****.**"], description="description...", expires="never", extra_keys={"my_extra": { "description": "an extra" }}, ) assert markdown.extra_info(event) == [("my_extra", "an extra")] # We don't currently support extra info for types other than events. other = metrics.Timespan( type="timespan", category="category", name="metric", bugs=[42], time_unit="day", notification_emails=["*****@*****.**"], description="description...", expires="never", ) assert len(markdown.extra_info(other)) == 0
def test_identifier(): """ Test that the identifier is created correctly. """ m = metrics.Timespan( type='timespan', category='category', name='metric', bugs=[42], time_unit='day', notification_emails=['*****@*****.**'], description='description...', ) assert m.identifier() == "category.metric"
def test_identifier_glean_category(): """ Test that the glean-internal identifier is created correctly. """ m = metrics.Timespan( type='timespan', category=metrics.Metric.glean_internal_metric_cat, name='metric', bugs=[42], time_unit='day', notification_emails=['*****@*****.**'], description='description...', ) assert m.identifier() == "metric"
def test_identifier_glean_category(): """ Test that the glean-internal identifier is created correctly. """ m = metrics.Timespan( type="timespan", category=metrics.Metric.glean_internal_metric_cat, name="metric", bugs=[42], time_unit="day", notification_emails=["*****@*****.**"], description="description...", expires="never", ) assert m.identifier() == "metric"
def test_extra_info_generator(): event = metrics.Event( type="event", category="category", name="metric", bugs=[42], notification_emails=["*****@*****.**"], description="description...", expires="never", extra_keys={"my_extra": { "description": "an extra" }}, ) assert markdown.extra_info(event) == [("my_extra", "an extra")] labeled = metrics.LabeledCounter( type="labeled_counter", category="category", name="metric", bugs=[42], notification_emails=["*****@*****.**"], description="description...", expires="never", labels=["label"], ) assert markdown.extra_info(labeled) == [("label", None)] # We currently support extra info only for events and labeled types. other = metrics.Timespan( type="timespan", category="category", name="metric", bugs=[42], time_unit="day", notification_emails=["*****@*****.**"], description="description...", expires="never", ) assert len(markdown.extra_info(other)) == 0