Пример #1
0
 def test_multiple_alerts(self):
     self.config.env.push_cib(remove=[
         "./configuration/alerts/alert[@id='alert1']",
         "./configuration/alerts/alert[@id='alert3']",
         "./configuration/alerts/alert[@id='alert4']",
     ])
     cmd_alert.remove_alert(self.env_assist.get_env(),
                            ["alert1", "alert3", "alert4"])
Пример #2
0
 def test_one_alert(self):
     self.config.env.push_cib(
         remove="./configuration/alerts/alert[@id='alert2']"
     )
     cmd_alert.remove_alert(
         self.env_assist.get_env(),
         ["alert2"]
     )
Пример #3
0
 def test_one_alert(self):
     self.config.env.push_cib(
         remove="./configuration/alerts/alert[@id='alert2']"
     )
     cmd_alert.remove_alert(
         self.env_assist.get_env(),
         ["alert2"]
     )
Пример #4
0
 def test_success(self):
     cmd_alert.remove_alert(self.mock_env, "alert")
     assert_xml_equal(
         """
             <cib validate-with="pacemaker-2.5">
                 <configuration>
                     <alerts>
                         <alert id="alert-1" path="/path"/>
                     </alerts>
                 </configuration>
             </cib>
         """, self.mock_env._get_cib_xml())
Пример #5
0
 def test_multiple_alerts(self):
     self.config.env.push_cib(
         remove=[
             "./configuration/alerts/alert[@id='alert1']",
             "./configuration/alerts/alert[@id='alert3']",
             "./configuration/alerts/alert[@id='alert4']",
         ]
     )
     cmd_alert.remove_alert(
         self.env_assist.get_env(),
         ["alert1", "alert3", "alert4"]
     )
Пример #6
0
 def test_multiple_alerts(self):
     cmd_alert.remove_alert(self.mock_env, ["alert1", "alert3", "alert4"])
     assert_xml_equal(
         """
             <cib validate-with="pacemaker-2.5">
                 <configuration>
                     <alerts>
                         <alert id="alert2" path="/path"/>
                     </alerts>
                 </configuration>
             </cib>
         """, self.mock_env._get_cib_xml())
     self.assertEqual([], self.mock_rep.report_item_list)
Пример #7
0
 def test_success(self):
     cmd_alert.remove_alert(self.mock_env, "alert")
     assert_xml_equal(
         """
             <cib validate-with="pacemaker-2.5">
                 <configuration>
                     <alerts>
                         <alert id="alert-1" path="/path"/>
                     </alerts>
                 </configuration>
             </cib>
         """,
         self.mock_env._get_cib_xml()
     )
Пример #8
0
 def test_multiple_alerts(self):
     cmd_alert.remove_alert(self.mock_env, ["alert1", "alert3", "alert4"])
     assert_xml_equal(
         """
             <cib validate-with="pacemaker-2.5">
                 <configuration>
                     <alerts>
                         <alert id="alert2" path="/path"/>
                     </alerts>
                 </configuration>
             </cib>
         """,
         self.mock_env._get_cib_xml()
     )
     self.assertEqual([], self.mock_rep.report_item_list)
Пример #9
0
 def test_alerts_dont_exist(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.remove_alert(
             self.env_assist.get_env(),
             ["unknown1", "alert1", "unknown2", "alert2"]
         ),
         [
             (
                 Severities.ERROR,
                 report_codes.ID_NOT_FOUND,
                 {
                     "context_type": "alerts",
                     "context_id": "",
                     "id": "unknown1",
                     "expected_types": ["alert"],
                 },
                 None
             ),
             (
                 Severities.ERROR,
                 report_codes.ID_NOT_FOUND,
                 {
                     "context_type": "alerts",
                     "context_id": "",
                     "id": "unknown2",
                     "expected_types": ["alert"],
                 },
                 None
             ),
         ],
         expected_in_processor=True
     )
Пример #10
0
 def test_alerts_dont_exist(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.remove_alert(
             self.env_assist.get_env(),
             ["unknown1", "alert1", "unknown2", "alert2"],
         ))
     self.env_assist.assert_reports([
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "context_type": "alerts",
                 "context_id": "",
                 "id": "unknown1",
                 "expected_types": ["alert"],
             },
             None,
         ),
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "context_type": "alerts",
                 "context_id": "",
                 "id": "unknown2",
                 "expected_types": ["alert"],
             },
             None,
         ),
     ])
Пример #11
0
 def test_not_existing_alert(self):
     assert_raise_library_error(
         lambda: cmd_alert.remove_alert(self.mock_env, "unknown"),
         (
             Severities.ERROR,
             report_codes.CIB_ALERT_NOT_FOUND,
             {"alert": "unknown"}
         )
     )
Пример #12
0
 def test_failure(self):
     report_list = [(Severities.ERROR, report_codes.ID_NOT_FOUND, {
         "id": "unknown"
     }), (Severities.ERROR, report_codes.ID_NOT_FOUND, {
         "id": "unknown2"
     })]
     assert_raise_library_error(
         lambda: cmd_alert.remove_alert(
             self.mock_env, ["unknown", "alert1", "unknown2", "alert2"]),
         *report_list)
     assert_report_item_list_equal(self.mock_rep.report_item_list,
                                   report_list)
Пример #13
0
 def test_alerts_dont_exist(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.remove_alert(self.env_assist.get_env(
         ), ["unknown1", "alert1", "unknown2", "alert2"]), [
             (Severities.ERROR, report_codes.ID_NOT_FOUND, {
                 "context_type": "alerts",
                 "context_id": "",
                 "id": "unknown1",
                 "id_description": "alert",
             }, None),
             (Severities.ERROR, report_codes.ID_NOT_FOUND, {
                 "context_type": "alerts",
                 "context_id": "",
                 "id": "unknown2",
                 "id_description": "alert",
             }, None),
         ],
         expected_in_processor=True)
Пример #14
0
 def test_failure(self):
     report_list = [
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {"id": "unknown"}
         ),
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {"id": "unknown2"}
         )
     ]
     assert_raise_library_error(
         lambda: cmd_alert.remove_alert(
             self.mock_env, ["unknown", "alert1", "unknown2", "alert2"]
         ),
         *report_list
     )
     assert_report_item_list_equal(
         self.mock_rep.report_item_list, report_list
     )
Пример #15
0
 def test_no_alert(self):
     self.config.env.push_cib()
     cmd_alert.remove_alert(self.env_assist.get_env(), [])
Пример #16
0
 def test_no_alert(self):
     self.config.env.push_cib()
     cmd_alert.remove_alert(
         self.env_assist.get_env(),
         []
     )
Пример #17
0
 def test_not_existing_alert(self):
     assert_raise_library_error(
         lambda: cmd_alert.remove_alert(self.mock_env, "unknown"),
         (Severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, {
             "alert": "unknown"
         }))