Ticket #3661: memcached-stats-fix.diff

File memcached-stats-fix.diff, 1.5 KB (added by dlsspy, 10 years ago)

Allow arguments to stats.

  • twisted/protocols/memcache.py

    === modified file 'twisted/protocols/memcache.py'
     
    589589        return cmdObj._deferred
    590590
    591591
    592     def stats(self):
     592    def stats(self, arg=None):
    593593        """
    594594        Get some stats from the server. It will be available as a dict.
    595595
     
    597597            statistics.
    598598        @rtype: L{Deferred}
    599599        """
    600         self.sendLine("stats")
     600        cmd = "stats"
     601        if arg:
     602            cmd = "stats " + arg
     603        self.sendLine(cmd)
    601604        cmdObj = Command("stats", values={})
    602605        self._current.append(cmdObj)
    603606        return cmdObj._deferred
  • twisted/test/test_memcache.py

    === modified file 'twisted/test/test_memcache.py'
     
    190190            "STAT foo bar\r\nSTAT egg spam\r\nEND\r\n",
    191191            {"foo": "bar", "egg": "spam"})
    192192
     193    def test_stats_with_arg(self):
     194        """
     195        Test retrieving server statistics via the
     196        L{MemCacheProtocol.stats} command with an argument: it should
     197        parse the data sent by the server and call back the resulting
     198        L{Deferred} with a dictionary of the received statistics.
     199        """
     200        return self._test(self.proto.stats("blah"), "stats blah\r\n",
     201            "STAT foo bar\r\nSTAT egg spam\r\nEND\r\n",
     202            {"foo": "bar", "egg": "spam"})
     203
    193204
    194205    def test_version(self):
    195206        """