summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGiuseppe Lavagetto <lavagetto@gmail.com>2014-03-20 10:04:58 +0100
committerGiuseppe Lavagetto <lavagetto@gmail.com>2014-03-20 10:04:58 +0100
commit04b65a1c7f5cdaf42060d30ed944de129aef3c97 (patch)
treea2112650dbddf4001b6ab18de746d9aa9ede9981 /src
parentdbe98aa7421eaee3ea3ecc5445a71310a9f5a1cb (diff)
More stringent check on write()
Style changes to integration tests
Diffstat (limited to 'src')
-rw-r--r--src/etcd/client.py2
-rw-r--r--src/etcd/tests/integration/test_simple.py40
2 files changed, 8 insertions, 34 deletions
diff --git a/src/etcd/client.py b/src/etcd/client.py
index 726963a..7d81fc2 100644
--- a/src/etcd/client.py
+++ b/src/etcd/client.py
@@ -241,7 +241,7 @@ class Client(object):
"""
key = self._sanitize_key(key)
params = {}
- if value:
+ if value is not None:
params['value'] = value
if ttl:
diff --git a/src/etcd/tests/integration/test_simple.py b/src/etcd/tests/integration/test_simple.py
index 0ef1f7a..e13c94a 100644
--- a/src/etcd/tests/integration/test_simple.py
+++ b/src/etcd/tests/integration/test_simple.py
@@ -133,15 +133,10 @@ class TestSimple(EtcdIntegrationTest):
class TestErrors(EtcdIntegrationTest):
def test_is_not_a_file(self):
- """ INTEGRATION: try to write value to a directory """
+ """ INTEGRATION: try to write value to an existing directory """
- set_result = self.client.set('/directory/test-key', 'test-value')
-
- try:
- get_result = self.client.set('/directory', 'test-value')
- assert False
- except KeyError as e:
- pass
+ self.client.set('/directory/test-key', 'test-value')
+ self.assertRaises(KeyError, self.client.set, '/directory', 'test-value')
def test_test_and_set(self):
""" INTEGRATION: try test_and_set operation """
@@ -153,27 +148,14 @@ class TestErrors(EtcdIntegrationTest):
'test-value',
'old-test-value')
- try:
- set_result = self.client.test_and_set(
- '/test-key',
- 'new-value',
- 'old-test-value')
-
- assert False
- except ValueError as e:
- pass
+ self.assertRaises(ValueError, self.client.test_and_set, '/test-key', 'new-value', 'old-test-value')
def test_creating_already_existing_directory(self):
""" INTEGRATION: creating an already existing directory without
`prevExist=True` should fail """
self.client.write('/mydir', None, dir=True)
- try:
- self.client.write('/mydir', None, dir=True)
- assert False
- except KeyError as e:
- pass
-
+ self.assertRaises(KeyError, self.client.write, '/mydir', None, dir=True)
class TestClusterFunctions(EtcdIntegrationTest):
@@ -500,16 +482,8 @@ class TestAuthenticatedAccess(EtcdIntegrationTest):
client = etcd.Client(
protocol='https', port=6001, ca_cert=self.ca2_cert_path)
- try:
- set_result = client.set('/test_set', 'test-key')
- assert False
- except urllib3.exceptions.SSLError as e:
- assert True
-
- try:
- get_result = client.get('/test_set')
- except urllib3.exceptions.SSLError as e:
- assert True
+ self.assertRaises(urllib3.exceptions.SSLError, client.set, '/test-set', 'test-key')
+ self.assertRaises(urllib3.exceptions.SSLError, client.get, '/test-set')
def test_get_set_authenticated(self):
""" INTEGRATION: set/get a new value authenticated """