示例#1
0
 def test_one_recipient(self):
     self.config.env.push_cib(
         remove="./configuration/alerts/alert/recipient[@id='alert-recip1']"
     )
     cmd_alert.remove_recipient(
         self.env_assist.get_env(),
         ["alert-recip1"]
     )
示例#2
0
 def test_one_recipient(self):
     self.config.env.push_cib(
         remove="./configuration/alerts/alert/recipient[@id='alert-recip1']"
     )
     cmd_alert.remove_recipient(
         self.env_assist.get_env(),
         ["alert-recip1"]
     )
示例#3
0
 def test_multiple_recipients(self):
     self.config.env.push_cib(remove=[
         "./configuration/alerts/alert/recipient[@id='alert-recip1']",
         "./configuration/alerts/alert/recipient[@id='alert-recip2']",
         "./configuration/alerts/alert/recipient[@id='alert2-recip4']",
     ])
     cmd_alert.remove_recipient(
         self.env_assist.get_env(),
         ["alert-recip1", "alert-recip2", "alert2-recip4"])
示例#4
0
 def test_multiple_recipients(self):
     self.config.env.push_cib(
         remove=[
             "./configuration/alerts/alert/recipient[@id='alert-recip1']",
             "./configuration/alerts/alert/recipient[@id='alert-recip2']",
             "./configuration/alerts/alert/recipient[@id='alert2-recip4']",
         ]
     )
     cmd_alert.remove_recipient(
         self.env_assist.get_env(),
         ["alert-recip1", "alert-recip2", "alert2-recip4"]
     )
示例#5
0
 def test_success(self):
     cmd_alert.remove_recipient(self.mock_env, "alert-recipient")
     assert_xml_equal(
         """
         <cib validate-with="pacemaker-2.5">
             <configuration>
                 <alerts>
                     <alert id="alert" path="path">
                         <recipient id="alert-recipient-1" value="value"/>
                     </alert>
                 </alerts>
             </configuration>
         </cib>
         """, self.mock_env._get_cib_xml())
示例#6
0
 def test_recipient_not_found(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.remove_recipient(
             self.env_assist.get_env(),
             ["recipient", "alert-recip1", "alert2-recip1"],
         ))
     self.env_assist.assert_reports([
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "id": "recipient",
                 "expected_types": ["recipient"],
                 "context_type": "alerts",
                 "context_id": "",
             },
             None,
         ),
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "id": "alert2-recip1",
                 "expected_types": ["recipient"],
                 "context_type": "alerts",
                 "context_id": "",
             },
             None,
         ),
     ])
示例#7
0
 def test_success(self):
     cmd_alert.remove_recipient(self.mock_env, "alert-recipient")
     assert_xml_equal(
         """
         <cib validate-with="pacemaker-2.5">
             <configuration>
                 <alerts>
                     <alert id="alert" path="path">
                         <recipient id="alert-recipient-1" value="value"/>
                     </alert>
                 </alerts>
             </configuration>
         </cib>
         """,
         self.mock_env._get_cib_xml()
     )
示例#8
0
 def test_multiple_recipients(self):
     cmd_alert.remove_recipient(
         self.mock_env,
         ["alert-recipient1", "alert-recipient2", "alert2-recipient4"])
     assert_xml_equal(
         """
         <cib validate-with="pacemaker-2.5">
             <configuration>
                 <alerts>
                     <alert id="alert" path="path"/>
                     <alert id="alert2" path="path">
                         <recipient id="alert2-recipient3" value="value3"/>
                     </alert>
                 </alerts>
             </configuration>
         </cib>
         """, self.mock_env._get_cib_xml())
     self.assertEqual([], self.mock_rep.report_item_list)
示例#9
0
 def test_recipient_not_found(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.remove_recipient(self.env_assist.get_env(
         ), ["recipient", "alert-recip1", "alert2-recip1"]),
         [(Severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "recipient"
         }, None),
          (Severities.ERROR, report_codes.ID_NOT_FOUND, {
              "id": "alert2-recip1"
          }, None)],
         expected_in_processor=True)
示例#10
0
 def test_recipient_not_found(self):
     assert_raise_library_error(
         lambda: cmd_alert.remove_recipient(
             self.mock_env, "recipient"
         ),
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {"id": "recipient"}
         )
     )
示例#11
0
 def test_multiple_recipients(self):
     cmd_alert.remove_recipient(
         self.mock_env,
         ["alert-recipient1", "alert-recipient2", "alert2-recipient4"]
     )
     assert_xml_equal(
         """
         <cib validate-with="pacemaker-2.5">
             <configuration>
                 <alerts>
                     <alert id="alert" path="path"/>
                     <alert id="alert2" path="path">
                         <recipient id="alert2-recipient3" value="value3"/>
                     </alert>
                 </alerts>
             </configuration>
         </cib>
         """,
         self.mock_env._get_cib_xml()
     )
     self.assertEqual([], self.mock_rep.report_item_list)
示例#12
0
 def test_recipient_not_found(self):
     report_list = [(Severities.ERROR, report_codes.ID_NOT_FOUND, {
         "id": "recipient"
     }),
                    (Severities.ERROR, report_codes.ID_NOT_FOUND, {
                        "id": "alert2-recipient1"
                    })]
     assert_raise_library_error(
         lambda: cmd_alert.remove_recipient(self.mock_env, [
             "recipient", "alert-recipient1", "alert2-recipient1"
         ]), *report_list)
     assert_report_item_list_equal(self.mock_rep.report_item_list,
                                   report_list)
示例#13
0
 def test_recipient_not_found(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.remove_recipient(
             self.env_assist.get_env(),
             ["recipient", "alert-recip1", "alert2-recip1"]
         ),
         [
             (
                 Severities.ERROR,
                 report_codes.ID_NOT_FOUND,
                 {"id": "recipient"},
                 None
             ),
             (
                 Severities.ERROR,
                 report_codes.ID_NOT_FOUND,
                 {"id": "alert2-recip1"},
                 None
             )
         ],
         expected_in_processor=True
     )
示例#14
0
 def test_recipient_not_found(self):
     report_list = [
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {"id": "recipient"}
         ),
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {"id": "alert2-recipient1"}
         )
     ]
     assert_raise_library_error(
         lambda: cmd_alert.remove_recipient(
             self.mock_env,
             ["recipient", "alert-recipient1", "alert2-recipient1"]
         ),
         *report_list
     )
     assert_report_item_list_equal(
         self.mock_rep.report_item_list, report_list
     )
示例#15
0
 def test_no_recipient(self):
     self.config.env.push_cib()
     cmd_alert.remove_recipient(
         self.env_assist.get_env(),
         []
     )
示例#16
0
 def test_no_recipient(self):
     self.config.env.push_cib()
     cmd_alert.remove_recipient(self.env_assist.get_env(), [])
示例#17
0
 def test_recipient_not_found(self):
     assert_raise_library_error(
         lambda: cmd_alert.remove_recipient(self.mock_env, "recipient"),
         (Severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "recipient"
         }))