def test_dashboard_update_success(sfx_recorder, session, chart): with sfx_recorder.use_cassette('dashboard_update_success', serialize_with='prettyjson'): dashboard = Dashboard(session=session) \ .with_name('testy mctesterson') \ .with_api_token('foo') \ .with_charts(chart('lol')) dashboard.create() dashboard.update(name='updated_dashboard_name', description='updated_dashboard_description')
def test_dashboard_update_child_chart(sfx_recorder, session, chart): chart = chart('rawr') dashboard = Dashboard(session=session)\ .with_name('foobarium')\ .with_api_token('foo')\ .with_charts(chart) with sfx_recorder.use_cassette('dashboard_update_child_chart', serialize_with='prettyjson'): # We expect that updating the chart immediately shouldn't have # any effect on the state of the chart. dashboard.update() resp = dashboard.update() # We should only have one chart assert len(resp['charts']) == 1
def test_dashboard_update_failure(sfx_recorder, session, chart): chart = chart('lol') dashboard = Dashboard(session=session) \ .with_name('testy mctesterson') \ .with_api_token('foo') \ .with_charts(chart) with sfx_recorder.use_cassette('dashboard_update_failure', serialize_with='prettyjson'): # Just to make sure there are multiple dashboards exists, create a new # dashboard with the same name dashboard.create(force=True) dashboard.create(force=True) with pytest.raises(SignalAnalogError): # Verify that we can't update when multiple dashboards exist dashboard.update(name='updated_dashboard_name', description='updated_dashboard_description')
def test_dashboard_create_child_chart(sfx_recorder, session, chart): chart1 = chart('rawr') chart2 = chart('roar') dashboard = Dashboard(session=session)\ .with_name('bariumfoo')\ .with_api_token('foo')\ .with_charts(chart1) with sfx_recorder.use_cassette('dashboard_create_child_chart', serialize_with='prettyjson'): resp = dashboard.create() assert len(resp['charts']) == 1 # Simulate updating a configuration file. dashboard.options['charts'].append(chart2) resp_update = dashboard.update() assert len(resp_update['charts']) == 2
def test_dashboard_delete_child_chart(sfx_recorder, session, chart): chart1 = chart('rawr') chart2 = chart('roar') dashboard = Dashboard(session=session)\ .with_name('isley brothers')\ .with_api_token('foo')\ .with_charts(chart1, chart2) with sfx_recorder.use_cassette('dashboard_delete_child_chart', serialize_with='prettyjson'): resp = dashboard.create() assert len(resp['charts']) == 2 # Simulate removing a chart from a user's config. dashboard.options['charts'] = list(filter( lambda x: x.options != chart2.options, dashboard.options['charts'])) resp_delete = dashboard.update() # We should only have one chart assert len(resp_delete['charts']) == 1