Fix tests

This commit is contained in:
Markus Unterwaditzer 2014-04-14 14:17:42 +02:00
parent 6fcbce6cc6
commit 74ec709478
2 changed files with 5 additions and 5 deletions

View file

@ -145,7 +145,7 @@ class StorageTests(object):
assert not collections assert not collections
def test_discover_collection_arg(self): def test_discover_collection_arg(self):
args = self.get_storage_args(collection='lol') args = self.get_storage_args(collection='test2')
with pytest.raises(TypeError) as excinfo: with pytest.raises(TypeError) as excinfo:
list(self.storage_class.discover(**args)) list(self.storage_class.discover(**args))

View file

@ -136,6 +136,8 @@ class DavStorage(Storage):
def _check_response(response): def _check_response(response):
if response.status_code == 412: if response.status_code == 412:
raise exceptions.PreconditionFailed(response.reason) raise exceptions.PreconditionFailed(response.reason)
if response.status_code == 404:
raise exceptions.NotFoundError(response.reason)
response.raise_for_status() response.raise_for_status()
def get(self, href): def get(self, href):
@ -158,7 +160,7 @@ class DavStorage(Storage):
data=data, data=data,
headers=self._default_headers() headers=self._default_headers()
) )
response.raise_for_status() self._check_response(response)
root = etree.XML(response.content) # etree only can handle bytes root = etree.XML(response.content) # etree only can handle bytes
rv = [] rv = []
hrefs_left = set(hrefs) hrefs_left = set(hrefs)
@ -190,7 +192,7 @@ class DavStorage(Storage):
def has(self, href): def has(self, href):
try: try:
self.get(href) self.get(href)
except exceptions.PreconditionFailed: except exceptions.NotFoundError:
return False return False
else: else:
return True return True
@ -240,8 +242,6 @@ class DavStorage(Storage):
href, href,
headers=headers headers=headers
) )
if response.status_code == 404:
raise exceptions.NotFoundError(href)
self._check_response(response) self._check_response(response)
def _list(self, xml): def _list(self, xml):