Exemple #1
0
    def setUp(self):
        cwd = os.path.dirname(os.path.abspath(__file__))
        fname = os.path.join(cwd, 'http_response_fixture.json')

        with open(fname) as f:
            self.fixture = json.load(f)

        self.etcd = Etcd(conn_cls=MockEtcdHTTPConnect, fixture=self.fixture)
Exemple #2
0
class EtcdTest(unittest.TestCase):

    def setUp(self):
        cwd = os.path.dirname(os.path.abspath(__file__))
        fname = os.path.join(cwd, 'http_response_fixture.json')

        with open(fname) as f:
            self.fixture = json.load(f)

        self.etcd = Etcd(conn_cls=MockEtcdHTTPConnect, fixture=self.fixture)


    def tearDown(self):
        pass


    def test_get_key(self):
        requests = self.fixture.get('get')

        for key, data in requests.iteritems():
            result = self.etcd.get(key)
            self.assertTrue(result == data['obj'])


    def test_get_key_raw(self):
        requests = self.fixture.get('get')

        for key, data in requests.iteritems():
            result = self.etcd.get(key, raw=True)
            self.assertTrue(result == data['response'])

    def test_put_key(self):
        requests = self.fixture.get('put')

        for key, data in requests.iteritems():
            result = self.etcd.put(key, data['data'])
            self.assertTrue(result)