def test_success(self, mock_get_incident, mock_get_rules, circuits_app, scheduler_type, scheduler_type_value, scheduler_rule_name, scheduler_rule_parameters, scheduler_label_prefix, incident_id, object_id, row_id, expected_results): """ Test calling with sample values for the parameters """ setup_mock_incident(mock_get_incident) setup_mock_actions(mock_get_rules) rule_label = u"{}_{}".format(scheduler_label_prefix, yyyymmdd) if scheduler_type == "date": dt = ResilientScheduler.get_interval("2h", date=True) scheduler_type_value = dt.strftime('%Y-%m-%d %H:%M:%S') function_params = { "scheduler_type": scheduler_type, "scheduler_type_value": scheduler_type_value, "scheduler_rule_name": scheduler_rule_name, "scheduler_rule_parameters": scheduler_rule_parameters, "scheduler_label_prefix": rule_label, "incident_id": incident_id, "object_id": object_id, "row_id": row_id } results = call_create_a_scheduled_rule_function( circuits_app, function_params) assert results['success']
def test_failure_object_id_mismatch( self, mock_incident, mock_rules, circuits_app, scheduler_type, scheduler_type_value, scheduler_rule_name, scheduler_rule_parameters, scheduler_label_prefix, incident_id, object_id, row_id, expected_results): """ Test calling with sample values for the parameters """ setup_mock_incident(mock_incident) setup_mock_actions(mock_rules, object_type=4) function_params = { "scheduler_type": scheduler_type, "scheduler_type_value": scheduler_type_value, "scheduler_rule_name": scheduler_rule_name, "scheduler_rule_parameters": scheduler_rule_parameters, "scheduler_label_prefix": scheduler_label_prefix, "incident_id": incident_id, "object_id": object_id, "row_id": row_id } with pytest.raises(Exception): results = call_create_a_scheduled_rule_function( circuits_app, function_params)
def test_success(self, mock_get_incident, mock_get_rules, circuits_app, scheduler_type, scheduler_type_value, scheduler_rule_name, scheduler_rule_parameters, scheduler_label_prefix, incident_id, object_id, row_id, expected_results): """ Test calling with sample values for the parameters """ setup_mock_incident(mock_get_incident) setup_mock_actions(mock_get_rules) now = datetime.datetime.now() yyyymmdd = now.strftime('%s') rule_label = u"{}_{}".format(scheduler_label_prefix, yyyymmdd) function_params = { "scheduler_type": scheduler_type, "scheduler_type_value": scheduler_type_value, "scheduler_rule_name": scheduler_rule_name, "scheduler_rule_parameters": scheduler_rule_parameters, "scheduler_label_prefix": rule_label, "incident_id": incident_id, "object_id": object_id, "row_id": row_id } results = call_create_a_scheduled_rule_function( circuits_app, function_params) assert results['success'] job_id = results['content']['id'] # list job = self.check_job(circuits_app, incident_id, job_id) if not job: raise LookupError("missing scheduled rule") # pause function_params = {"scheduler_label": job_id} results = call_scheduled_rule_pause_function(circuits_app, function_params) assert results['success'] job = self.check_job(circuits_app, incident_id, job_id, is_enabled=False) if not job: raise LookupError("missing scheduled rule") # resume results = call_scheduled_rule_resume_function(circuits_app, function_params) assert results['success'] job = self.check_job(circuits_app, incident_id, job_id) if not job: raise LookupError("missing scheduled rule") # remove results = call_remove_a_scheduled_rule_function( circuits_app, function_params) assert results['success'] job = self.check_job(circuits_app, incident_id, job_id) if job: raise LookupError("scheduled rule not removed")