def test_group(self, mock_find_group, mock_find_target): mock_find_target.side_effect = acl_lib.AclTargetNotFound("group_id") mock_find_group.return_value = "group_el" self.assertEqual("group_el", cmd_acl._get_target_or_group(self.cib, "group_id")) mock_find_target.assert_called_once_with(self.cib, "group_id") mock_find_group.assert_called_once_with(self.cib, "group_id")
def test_not_found(self, mock_find_group, mock_find_target): mock_find_target.side_effect = acl_lib.AclTargetNotFound("id") mock_find_group.side_effect = acl_lib.AclGroupNotFound("id") assert_raise_library_error( lambda: cmd_acl._get_target_or_group(self.cib, "id"), (Severities.ERROR, report_codes.ID_NOT_FOUND, {"id": "id", "id_description": "user/group"}), ) mock_find_target.assert_called_once_with(self.cib, "id") mock_find_group.assert_called_once_with(self.cib, "id")
def test_not_found(self, mock_find_group, mock_find_target): mock_find_target.side_effect = acl_lib.AclTargetNotFound("id") mock_find_group.side_effect = acl_lib.AclGroupNotFound("id") assert_raise_library_error( lambda: cmd_acl._get_target_or_group(self.cib, "id"), (Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "id", "id_description": "user/group", })) mock_find_target.assert_called_once_with(self.cib, "id") mock_find_group.assert_called_once_with(self.cib, "id")
def test_target(self, mock_find_group, mock_find_target): mock_find_target.return_value = "target_el" self.assertEqual("target_el", cmd_acl._get_target_or_group(self.cib, "target_id")) mock_find_target.assert_called_once_with(self.cib, "target_id") self.assertEqual(0, mock_find_group.call_count)