當前位置: 首頁>>代碼示例>>Python>>正文


Python Worksheet._usercode_error方法代碼示例

本文整理匯總了Python中dirigible.sheet.worksheet.Worksheet._usercode_error方法的典型用法代碼示例。如果您正苦於以下問題:Python Worksheet._usercode_error方法的具體用法?Python Worksheet._usercode_error怎麽用?Python Worksheet._usercode_error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dirigible.sheet.worksheet.Worksheet的用法示例。


在下文中一共展示了Worksheet._usercode_error方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_api_view_should_return_errors_and_no_values_if_unjsonify_worksheet_result_has_errors

# 需要導入模塊: from dirigible.sheet.worksheet import Worksheet [as 別名]
# 或者: from dirigible.sheet.worksheet.Worksheet import _usercode_error [as 別名]
    def test_api_view_should_return_errors_and_no_values_if_unjsonify_worksheet_result_has_errors(self, mock_get_object):
        mock_sheet = mock_get_object.return_value
        mock_sheet.owner = self.user

        worksheet = Worksheet()
        worksheet[1, 3].formula = '=string'
        worksheet[1, 3].value = 'test value'
        worksheet._usercode_error = {
            "message": "I am an error message",
            "line": 2
        }
        mock_sheet.unjsonify_worksheet.side_effect = lambda: worksheet
        mock_sheet.allow_json_api_access = True
        self.request.method = 'POST'
        self.request.POST['api_key'] = mock_sheet.api_key = 'key'

        expected_json = {
            "usercode_error" : {
                "message": "I am an error message",
                "line": "2"
            }
        }

        actual = calculate_and_get_json_for_api(self.request, self.user.username, self.sheet.id)

        self.assertFalse(mock_sheet.save.called)
        self.assertTrue(isinstance(actual, HttpResponse))
        self.assertEquals(actual.content, json.dumps(expected_json))
開發者ID:bwhmather,項目名稱:dirigible-spreadsheet,代碼行數:30,代碼來源:test_views_api_0_1.py

示例2: api_json_to_worksheet

# 需要導入模塊: from dirigible.sheet.worksheet import Worksheet [as 別名]
# 或者: from dirigible.sheet.worksheet.Worksheet import _usercode_error [as 別名]
def api_json_to_worksheet(sheet_json):
    sheet_values = jsonlib.loads(sheet_json)
    worksheet = Worksheet()

    worksheet.name = sheet_values.get('name', 'Untitled')
    for key, value in sheet_values.iteritems():
        if key == "usercode_error":
            worksheet._usercode_error = value
        elif isinstance(value, dict):
            rows = value
            col = int(key)
            for row, value in rows.iteritems():
                row = int(row)
                worksheet[col, row].value = value
    return worksheet
開發者ID:bwhmather,項目名稱:dirigible-spreadsheet,代碼行數:17,代碼來源:calculate.py

示例3: test_to_ui_json_meta_data_includes_usercode_errors

# 需要導入模塊: from dirigible.sheet.worksheet import Worksheet [as 別名]
# 或者: from dirigible.sheet.worksheet.Worksheet import _usercode_error [as 別名]
 def test_to_ui_json_meta_data_includes_usercode_errors(self):
     sheet = Sheet(width=10, height=5)
     worksheet = Worksheet()
     worksheet._usercode_error = {
         'message' : 'ABC',
         'line' : 123
     }
     expected_json_contents = {
         'width': sheet.width,
         'height': sheet.height,
         'name': sheet.name,
         'usercode_error' : {
             'message' : 'ABC',
             'line' : '123'
         }
     }
     self.assertEquals(json.loads(sheet_to_ui_json_meta_data(sheet, worksheet)), expected_json_contents)
開發者ID:bwhmather,項目名稱:dirigible-spreadsheet,代碼行數:19,代碼來源:test_ui_jsonifier.py

示例4: test_calculate_clears_previous_worksheet_usercode_error

# 需要導入模塊: from dirigible.sheet.worksheet import Worksheet [as 別名]
# 或者: from dirigible.sheet.worksheet.Worksheet import _usercode_error [as 別名]
 def test_calculate_clears_previous_worksheet_usercode_error(self, mock_evaluate_formulae_in_context, mock_execute_usercode):
     worksheet = Worksheet()
     worksheet._usercode_error = "Argh!"
     calculate(worksheet, sentinel.usercode, sentinel.private_key)
     self.assertEquals(worksheet._usercode_error, None)
開發者ID:bwhmather,項目名稱:dirigible-spreadsheet,代碼行數:7,代碼來源:test_calculate.py

示例5: test_worksheet_with_data_to_json

# 需要導入模塊: from dirigible.sheet.worksheet import Worksheet [as 別名]
# 或者: from dirigible.sheet.worksheet.Worksheet import _usercode_error [as 別名]
    def test_worksheet_with_data_to_json(self):
        self.maxDiff = None

        worksheet = Worksheet()

        worksheet.B29.formula = "a constant"
        worksheet.B29.value = 56
        worksheet.B29.formatted_value = "fifty-six"
        worksheet.B29.error = "b0rken"

        worksheet.C29.formula = "another constant"
        worksheet.C29.value = ["value", "is", "a", "list"]
        worksheet.C29.formatted_value = "[the same list]"

        class UnJSONableObject(object):
            def __str__(self):
                return "The result of str-ing the object"
        worksheet.D29.formula = None
        worksheet.D29.value = UnJSONableObject()
        worksheet.D29.formatted_value = "The formatted object"

        worksheet.E29.formula = '=1 + 2'
        worksheet.E29.value = 3
        worksheet.E29.formatted_value = "Three"

        worksheet._console_text = "The console text"
        worksheet._usercode_error = { "message": "The usercode error", "line": 23 }

        worksheet_json = worksheet_to_json(worksheet)

        self.assertEquals(
            json.loads(worksheet_json),
            {
                u"2,29" : {
                    u"formula" : u"a constant",
                    u"value" : 56,
                    u"formatted_value": u"fifty-six",
                    u"error": u"b0rken"
                },

                u"3,29" : {
                    u"formula" : u"another constant",
                    u"value" : [u"value", u"is", u"a", u"list"],
                    u"formatted_value": u"[the same list]"
                },

                u"4,29" : {
                    u"formula" : None,
                    u"formatted_value": u"The formatted object",
                },

                u"5,29" : {
                    u"formula" : u"=1 + 2",
                    u"python_formula" : u"1 + 2",
                    u"value": 3,
                    u"formatted_value": u"Three",
                },

                u"_console_text": u"The console text",
                u"_usercode_error": { u"message": u"The usercode error", u"line": 23 },
            }
        )
開發者ID:bwhmather,項目名稱:dirigible-spreadsheet,代碼行數:64,代碼來源:test_worksheet.py


注:本文中的dirigible.sheet.worksheet.Worksheet._usercode_error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。