def test_update_errors(self): cmd = Command() self.assertDictEqual({}, cmd.errors) errors = {'foo': 'foomsg'} cmd.update_errors(**errors) self.assertDictEqual(errors, cmd.errors) errors['bar'] = 'barmsg' cmd.update_errors(**errors) self.assertDictEqual(errors, cmd.errors)
def _to_command(self, node_or_command): if isinstance(node_or_command, Command): return node_or_command cmd = Command() try: node_key = to_node_key(node_or_command) cmd.result = node_key except: pass return cmd
def _to_command(self, node_or_command): if isinstance(node_or_command, Command): return node_or_command cmd = Command() try: node_key = to_node_key(node_or_command) cmd.result = node_key except: cmd.add_error('node', 'Invalid Node') return cmd
def logged_user(request): """ Returns a command that retrieves the current logged user based on secure cookie If there is no logged user, the result from command is None """ dct = cookie_facade.retrive_cookie_data(request, USER_COOKIE_NAME).execute().result if dct is None: return Command() return NodeSearch(dct['id'])
def cmd_with_handle_previous_mocked(): c = Command() c.handle_previous = Mock() return c
def __init__(self, name): Command.__init__(self, name=name)