def execute(self, request): '''Execute a new ``request``. ''' handle = None if request: request[0] = command = force_native_str(request[0]).lower() info = COMMANDS_INFO.get(command) if info: handle = getattr(self.store, info.method_name) # if self.channels or self.patterns: if command not in self.store.SUBSCRIBE_COMMANDS: return self.reply_error(self.store.PUBSUB_ONLY) if self.blocked: return self.reply_error('Blocked client cannot request') if self.transaction is not None and command not in 'exec': self.transaction.append((handle, request)) return self._transport.write(self.store.QUEUED) self._execute_command(handle, request)
def test_force_native_str(self): self.assertEqual(force_native_str('ciao'), 'ciao') self.assertEqual(force_native_str(b'ciao'), 'ciao') self.assertEqual(force_native_str(1), '1') self.assertEqual(force_native_str((1, 'b')), str((1, 'b')))
def test_force_native_str(self): self.assertEqual(force_native_str("ciao"), "ciao") self.assertEqual(force_native_str(b"ciao"), "ciao") self.assertEqual(force_native_str(1), "1") self.assertEqual(force_native_str((1, "b")), str((1, "b")))