File: test_autoconf.py

package info (click to toggle)
pylibmc 1.6.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 576 kB
  • sloc: ansic: 2,398; python: 1,014; makefile: 95
file content (23 lines) | stat: -rw-r--r-- 941 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pytest import raises
from pylibmc import autoconf
from tests import PylibmcTestCase

class AutoConfTests(PylibmcTestCase):
    def test_no_autoconf(self):
        self.mc.delete('AmazonElastiCache:cluster')
        with raises(autoconf.NoAutoconfFound):
            mc = autoconf.elasticache()

    def test_autoconf(self):
        addrtup = (self.memcached_host, self.memcached_port)
        self.mc.set('AmazonElastiCache:cluster', ('12\nlocalhost|%s|%s' % addrtup).encode('ascii'))
        mc = autoconf.elasticache(address=('%s:%s' % addrtup))
        assert mc.set('a', 'b')
        assert mc.get('a') == 'b'

    def test_autoconf_only_cname(self):
        addrtup = (self.memcached_host, self.memcached_port)
        self.mc.set('AmazonElastiCache:cluster', ('12\n%s||%s' % addrtup).encode('ascii'))
        mc = autoconf.elasticache(address=('%s:%s' % addrtup))
        assert mc.set('a', 'b')
        assert mc.get('a') == 'b'