def test_ts_list_charts_mixin(): """TimeSeries and ListCharts can set legend options. But not others.""" opt = {'fields': [{'property': 'foo', 'enabled': False}]} ts = TimeSeriesChart()\ .with_legend_options([FieldOption('foo', enabled=False)]) assert ts.chart_options['legendOptions'] == opt lc = ListChart()\ .with_legend_options([FieldOption('foo', enabled=False)]) assert lc.chart_options['legendOptions'] == opt with pytest.raises(Exception): SingleValueChart().with_legend_options(FieldOption('foo', enabled=False))
def test_chart_with_empties(value): with pytest.raises(ValueError): Chart().with_name(value) Chart().with_description(value) Chart().with_program() FieldOption(value, False) PublishLabelOptions(value, value, value, value, value)
def test_sfx_field_options_happy(): """We also expect that string values are still valid.""" expected = {'fields': [{'property': 'foo', 'enabled': False}]} ts = TimeSeriesChart()\ .with_legend_options([FieldOption('foo', enabled=False)]) assert ts.chart_options['legendOptions'] == expected
def test_sfx_field_options_invalid(): """Other enums should not be allowed.""" class InvalidEnum(Enum): foo = 'bar' with pytest.raises(ValueError): ts = TimeSeriesChart()\ .with_legend_options([ FieldOption(InvalidEnum.foo, enabled=False) ])
def test_sfx_field_options_enum(): """We expect values from the SignalFxFieldOption enum to be serialized. """ expected = {'fields': [{'property': 'sf_originatingMetric', 'enabled': False}]} ts = TimeSeriesChart()\ .with_legend_options([ FieldOption(SignalFxFieldOption.plot_name, enabled=False) ]) assert ts.chart_options['legendOptions'] == expected
def test_ts_chart_with_field_options_disabled(): field_opt = FieldOption('bar', enabled=False) opt = {'fields': [field_opt.to_dict()]} chart = TimeSeriesChart().with_legend_options([field_opt]) assert chart.chart_options['legendOptions'] == opt
def test_ts_chart_with_field_options(): field_opt = FieldOption('foo') opt = {'fields': [field_opt.to_dict()]} chart = TimeSeriesChart().with_legend_options([field_opt]) assert chart.chart_options['legendOptions'] == opt