def test_notification_set_scenario(scenario1): params = dict(description='description goes here.', notifier='email-notifier', on_start=True) note = Notification(name='note', parameters=params) note.scenario = scenario1 assert note.scenario
def test_notification_set_on_demand(): params = dict(description='description goes here.', notifier='email-notifier', on_demand=True) note = Notification(name='note', parameters=params) with pytest.raises(AttributeError): note.on_demand = False
def test_notification_build_profile(): params = dict( description='description goes here.', notifier='email-notifier', on_start=True ) note = Notification(name='note', parameters=params) assert isinstance(note.profile(), dict)
def test_notification_set_notifier(): params = dict( name='note', description='description goes here.', ) note = Notification(parameters=params) with pytest.raises(AttributeError) as ex: note.notifier = 'blah'
def test_notification_set_on_tasks(): tasks = ['validate', 'provision'] params = dict(description='description goes here.', notifier='email-notifier', on_tasks=tasks) note = Notification(name='note', parameters=params) with pytest.raises(AttributeError): note.on_tasks = tasks
def test_notification_set_credential(): params = dict( description='description goes here.', notifier='email-notifier' ) note = Notification(name='note', parameters=params) with pytest.raises(AttributeError): note.credential = 'gmail'
def test_notification_no_credential(): params = dict( description='description goes here.', notifier='email-notifier' ) note = Notification(name='note', parameters=params) assert not note.credential
def test_create_notification_with_name_in_parameters(): params = dict(name='note', description='description goes here.', notifier='email-notifier') note = Notification(parameters=params) assert note.name == 'note'
def test_create_notification_on_demand(): params = dict(description='description goes here.', notifier='email-notifier', on_demand=True) note = Notification(name='note', parameters=params) assert note.on_demand assert getattr(note, 'on_start') is None
def test_create_notification_without_notifier(): params = dict( name='note', description='description goes here.' ) note = Notification(parameters=params) assert note.notifier
def test_notification_credential(config): params = dict( description='description goes here.', notifier='email-notifier' ) note = Notification(name='note', parameters=params, config=config) assert note.credential is None
def test_create_notification_with_name(): params = dict( description='description goes here.', notifier='email-notifier' ) note = Notification(name='note', parameters=params) assert isinstance(note, Notification)
def test_notification_load_params(): params = dict( description='description goes here.', notifier='email-notifier', foo='bar' ) note = Notification(name='note', parameters=params) assert note.foo
def test_create_notification_on_tasks(): tasks = ['validate', 'provision'] params = dict(description='description goes here.', notifier='email-notifier', on_tasks=tasks) note = Notification(name='note', parameters=params) assert note.on_tasks assert set(note.on_tasks).intersection(tasks)
def test_create_notification_on_success_and_failure(): params = dict(description='description goes here.', notifier='email-notifier', on_success=True, on_failure=False) note = Notification(name='note', parameters=params) assert note.on_success assert not note.on_failure
def test_create_notification_default_triggers(): params = dict( description='description goes here.', notifier='email-notifier' ) note = Notification(name='note', parameters=params) assert note.on_success assert note.on_failure
def test_create_notification_unregistered_notifier(): params = dict( name='note', description='description goes here.', notifier='blah' ) with pytest.raises(TefloResourceError) as ex: Notification(parameters=params)
def test_create_notification_without_name(): params = dict( description='description goes here.', notifier='email-notifier' ) with pytest.raises(TefloResourceError): Notification(parameters=params)
def test_notify_no_config(scenario, note_params): setattr(scenario, 'passed_tasks', ['validate']) setattr(scenario, 'failed_tasks', []) setattr(scenario, 'overall_status', 0) note = Notification(name='note', parameters=note_params, config=getattr(scenario, 'config')) setattr(note, 'scenario', scenario) emailer = EmailNotificationPlugin(note) with pytest.raises(TefloNotifierError): emailer.notify()
def notification_default_resource(default_note_params, config): params = copy.deepcopy(default_note_params) params['on_tasks'] = ['validate'] return Notification(name='note02', parameters=params, config=config)
def notification_on_failure_resource(default_note_params, config): params = copy.deepcopy(default_note_params) params['on_tasks'] = ['report'] params['on_failure'] = True return Notification(name='note04', parameters=params, config=config)
def notification_on_success_resource(default_note_params, config): params = copy.deepcopy(default_note_params) params['on_tasks'] = ['provision'] params['on_success'] = True return Notification(name='note03', parameters=params, config=config)
def notification_on_demand_resource(default_note_params, config): params = copy.deepcopy(default_note_params) params['on_demand'] = True return Notification(name='note05', parameters=params, config=config)