def widget(self): self.method_result = WidgetResult(self.WidgetStub()) self.value_to_return = 'ignored in this case' self.expected_response = '<the widget contents><script type="text/javascript">javascriptsome</script>' self.exception_response = Exception self.expected_charset = self.method_result.encoding self.expected_content_type = 'text/html' self.results_match = lambda x, y: x == y
def test_what_is_included_in_coactive_widgets(web_fixture, coactive_scenarios): fixture = coactive_scenarios fixture.view.page = fixture.page with expected(fixture.expected_exception, fixture.expected_exception_regex): coactive_widgets = WidgetResult( fixture.result_widget, as_json_and_result=True).get_coactive_widgets_recursively( fixture.result_widget) assert set(coactive_widgets) == set(fixture.expected_coactive_widgets)
def __init__(self, view): super(WidgetWithRemoteMethod, self).__init__(view) method_result = WidgetResult(fixture.WidgetStub(view), as_json_and_result=True) def change_something(): fixture.changes_made = True if fixture.exception: raise DomainException('ex') remote_method = RemoteMethod('amethod', change_something, default_result=method_result, immutable=False) view.add_resource(remote_method)
def widget_as_json(self): self.method_result = WidgetResult(self.WidgetStub(), as_json_and_result=True) self.value_to_return = 'ignored in this case' self.expected_response = { 'widget': '<the widget contents><script type="text/javascript">javascriptsome</script>', 'success': True } self.expected_charset = self.method_result.encoding self.expected_content_type = 'application/json' def results_match(expected, actual): return json.loads(actual) == expected self.results_match = results_match
def __init__(self, view): super().__init__(view) method_result = WidgetResult(fixture.WidgetStub(view), as_json_and_result=True) def change_something(): fixture.changes_made = True if fixture.exception: raise DomainException( message='breaking intentionally', handled_inline=fixture.handle_inline) remote_method = RemoteMethod(view, 'amethod', change_something, default_result=method_result, immutable=False, disable_csrf_check=True) view.add_resource(remote_method)
def __init__(self, view): super(WidgetWithRemoteMethod, self).__init__(view) coactive_widgets = [ self.add_child( CoactiveWidgetStub(view, 'coactive1', [ self.add_child( CoactiveWidgetStub(view, 'coactive2', [])) ])) ] result_widget = self.add_child(CoactiveWidgetStub( view, 'main', [])) result_widget.add_child( CoactiveWidgetStub(view, 'child', coactive_widgets)) method_result = WidgetResult(result_widget, as_json_and_result=True) remote_method = RemoteMethod(view, 'amethod', lambda: None, default_result=method_result) view.add_resource(remote_method)