예제 #1
0
파일: test_booth.py 프로젝트: gmelikov/pcs
 def test_raises_when_implicit_site_not_found_in_cib(
         self, mock_find_bound_ip):
     mock_find_bound_ip.return_value = []
     assert_raise_library_error(
         lambda: commands._ticket_operation(
             "grant", _env_fixture("booth_name"), "ABC", site_ip=None),
         (Severities.ERROR,
          report_codes.BOOTH_CANNOT_DETERMINE_LOCAL_SITE_IP, {}),
     )
예제 #2
0
파일: test_booth.py 프로젝트: gmelikov/pcs
 def test_raises_when_command_fail(self):
     mock_run = mock.Mock(return_value=("some message", "error", 1))
     mock_env = mock.MagicMock(cmd_runner=mock.Mock(
         return_value=mock.MagicMock(run=mock_run)))
     assert_raise_library_error(
         lambda: commands._ticket_operation(
             "grant", mock_env, "ABC", site_ip="1.2.3.4"),
         (Severities.ERROR, report_codes.BOOTH_TICKET_OPERATION_FAILED, {
             "operation": "grant",
             "reason": "error\nsome message",
             "site_ip": "1.2.3.4",
             "ticket_name": "ABC",
         }),
     )
예제 #3
0
 def test_raises_when_implicit_site_not_found_in_cib(
     self, mock_find_bound_ip
 ):
     mock_find_bound_ip.return_value = []
     assert_raise_library_error(
         lambda: commands._ticket_operation(
             "grant", _env_fixture("booth_name"), "ABC", site_ip=None
         ),
         (
             Severities.ERROR,
             report_codes.BOOTH_CANNOT_DETERMINE_LOCAL_SITE_IP,
             {}
         ),
     )
예제 #4
0
 def test_raises_when_command_fail(self):
     mock_run = mock.Mock(return_value=("some message", "error", 1))
     mock_env = mock.MagicMock(
         cmd_runner=mock.Mock(return_value=mock.MagicMock(run=mock_run))
     )
     assert_raise_library_error(
         lambda: commands._ticket_operation(
             "grant", mock_env, "ABC", site_ip="1.2.3.4"
         ),
         (
             Severities.ERROR,
             report_codes.BOOTH_TICKET_OPERATION_FAILED,
             {
                 "operation": "grant",
                 "reason": "error\nsome message",
                 "site_ip": "1.2.3.4",
                 "ticket_name": "ABC",
             }
         ),
     )