def test_dashboard_group_update_success(sfx_recorder, session): # Enforcing the request body helps to prevent a defect from being masked due to over-mocking # the requests/responses. with betamax.Betamax.configure() as config: initial_cassette_options = config.default_cassette_options[ 'match_requests_on'] config.default_cassette_options['match_requests_on'] = [ 'body', 'method', 'uri' ] with sfx_recorder.use_cassette('dashboard_group_update_success', serialize_with='prettyjson'): name = 'spaceX lol' updated_name = 'updated_dashboard_group_name' updated_team_id = 'updated_team_id' dashboard_group = DashboardGroup(session=session)\ .with_name(name)\ .with_api_token('foo') create_result = dashboard_group.create() update_result = dashboard_group\ .with_id(create_result['id'])\ .with_teams(updated_team_id)\ .update(name='updated_dashboard_group_name', description='updated_dashboard_group_description') assert create_result['name'] == name assert update_result['name'] == updated_name assert updated_team_id in update_result['teams'] with betamax.Betamax.configure() as config: config.default_cassette_options[ 'match_requests_on'] = initial_cassette_options
def test_dashboard_group_update_failure(sfx_recorder, session): dashboard_group = DashboardGroup(session=session) \ .with_name('spaceX') \ .with_api_token('foo') with sfx_recorder.use_cassette('dashboard_group_update_failure', serialize_with='prettyjson'): # Just to make sure there are multiple dashboard groups exists, # create a new dashboard group with the same name dashboard_group.create(force=True) dashboard_group.create(force=True) with pytest.raises(SignalAnalogError): # Verify that we can't update when multiple dashboard groups exist dashboard_group.update( name='updated_dashboard_group_name', description='updated_dashboard_group_description')
def test_dashboard_group_with_dashboard_create_force_success(sfx_recorder, session, dashboard): name = 'spaceX' dashboard_group = DashboardGroup(session=session)\ .with_name(name) \ .with_dashboards(dashboard('Falcon99', 'chart1'))\ .with_api_token('foo') with sfx_recorder.use_cassette( 'dashboard_group_with_dashboard_create_success_force', serialize_with='prettyjson'): result = dashboard_group.create(force=True) assert result['name'] == name assert len(result['dashboards']) == 1
def test_dashboard_group_with_dashboard_create_success(): name = 'spaceX unique' group = DashboardGroup(session=global_session)\ .with_name(name)\ .with_dashboards(mk_dashboard('Falcon99', 'chart1'))\ .with_api_token('foo')\ with global_recorder.use_cassette( 'dashboard_group_with_dashboard_create_success', serialize_with='prettyjson'): result = group.create() assert result['name'] == name assert len(result['dashboards']) == 1
def test_dashboard_group_with_dashboard_create_interactive_failure(confirm, sfx_recorder, session, dashboard): confirm.__getitem__.return_value = 'n' name = 'spaceX' dashboard_group = DashboardGroup(session=session) \ .with_name(name) \ .with_dashboards(dashboard('Falcon99', 'chart1')) \ .with_api_token('foo') with sfx_recorder.use_cassette( 'dashboard_group_with_dashboard_create_failure_interactive', serialize_with='prettyjson'): result = dashboard_group.create(interactive=True) assert result['name'] == name assert len(result['dashboards']) == 1
def test_dashboard_group_create_force_success(sfx_recorder, session): dashboard_group = DashboardGroup(session=session)\ .with_name('spaceX')\ .with_api_token('foo')\ with sfx_recorder.use_cassette('dashboard_group_create_success_force', serialize_with='prettyjson'): # Create our first dashboard group dashboard_group.create() with pytest.raises(SignalAnalogError): # Verify that we can't create it again dashboard_group.create() # Force the dashboard group to create itself again dashboard_group.create(force=True)
def test_dashboard_group_create_interactive_failure(confirm, sfx_recorder, session): confirm.__getitem__.return_value = 'n' dashboard_group = DashboardGroup(session=session) \ .with_name('spaceX') \ .with_api_token('foo') with sfx_recorder.use_cassette( 'dashboard_group_create_failure_interactive', serialize_with='prettyjson'): # Create our first dashboard_group dashboard_group.create() with pytest.raises(SignalAnalogError): # Verify that we can't create it again dashboard_group.create() dashboard_group.create(interactive=True)
def test_dashboard_group_update_success(sfx_recorder, session): name = 'spaceX lol' updated_name = 'updated_dashboard_group_name' with sfx_recorder.use_cassette('dashboard_group_update_success', serialize_with='prettyjson'): dashboard_group = DashboardGroup(session=session)\ .with_name(name)\ .with_api_token('foo') create_result = dashboard_group.create() update_result = dashboard_group\ .with_id(create_result['id'])\ .update(name='updated_dashboard_group_name', description='updated_dashboard_group_description') assert create_result['name'] == name assert update_result['name'] == updated_name
def test_dashboard_group_create_interactive_success(confirm): confirm.__getitem__.return_value = 'y' dashboard_group = DashboardGroup(session=global_session) \ .with_name('spaceX') \ .with_api_token('foo') with global_recorder.use_cassette( 'dashboard_group_create_success_interactive', serialize_with='prettyjson'): # Create our first dashboard group dashboard_group.create() with pytest.raises(SignalAnalogError): # Verify that we can't create it again dashboard_group.create() # Run the dashboard group creation in interactive mode dashboard_group.create(interactive=True)