当前位置: 首页>>代码示例>>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;未经允许,请勿转载。