diff --git a/kinto_http/__init__.py b/kinto_http/__init__.py index 751c732..a6a63be 100644 --- a/kinto_http/__init__.py +++ b/kinto_http/__init__.py @@ -254,11 +254,7 @@ def delete_bucket(self, bucket=None, safe=True, if_match=None, if_exists=False): resp, _ = self.session.request('delete', endpoint, headers=headers) return resp['data'] - def delete_buckets(self, safe=True, if_match=None, if_exists=False): - if if_exists: - return self._delete_if_exists('buckets', - safe=safe, - if_match=if_match) + def delete_buckets(self, safe=True, if_match=None): endpoint = self.get_endpoint('buckets') headers = self._get_cache_headers(safe, if_match=if_match) resp, _ = self.session.request('delete', endpoint, headers=headers) @@ -415,12 +411,7 @@ def delete_collection(self, collection=None, bucket=None, resp, _ = self.session.request('delete', endpoint, headers=headers) return resp['data'] - def delete_collections(self, bucket=None, safe=True, if_match=None, if_exists=False): - if if_exists: - return self._delete_if_exists('collections', - bucket=bucket, - safe=safe, - if_match=if_match) + def delete_collections(self, bucket=None, safe=True, if_match=None): endpoint = self.get_endpoint('collections', bucket=bucket) headers = self._get_cache_headers(safe, if_match=if_match) resp, _ = self.session.request('delete', endpoint, headers=headers) @@ -523,13 +514,7 @@ def delete_record(self, id, collection=None, bucket=None, return resp['data'] def delete_records(self, collection=None, bucket=None, - safe=True, if_match=None, if_exists=False): - if if_exists: - return self._delete_if_exists('records', - collection=collection, - bucket=bucket, - safe=safe, - if_match=if_match) + safe=True, if_match=None): endpoint = self.get_endpoint('records', bucket=bucket, collection=collection) diff --git a/kinto_http/tests/functional.py b/kinto_http/tests/functional.py index c0196d7..e751e08 100644 --- a/kinto_http/tests/functional.py +++ b/kinto_http/tests/functional.py @@ -94,10 +94,9 @@ def test_buckets_deletion(self): assert buckets[0]['id'] == 'mozilla' self.assertRaises(BucketNotFound, self.client.get_bucket, 'mozilla') - def test_buckets_deletion_if_exists(self): - self.client.create_bucket('mozilla') - self.client.delete_buckets() - self.client.delete_buckets(if_exists=True) + def test_buckets_deletion_when_no_buckets_exist(self): + deleted_buckets = self.client.delete_buckets() + assert len(deleted_buckets) == 0 def test_bucket_save(self): self.client.create_bucket('mozilla', permissions={'write': ['alexis']}) @@ -180,6 +179,11 @@ def test_groups_deletion(self): self.client.delete_groups(bucket='mozilla') assert len(self.client.get_groups(bucket='mozilla')) == 0 + def test_groups_deletion_when_no_groups_exist(self): + self.client.create_bucket('mozilla') + deleted_groups = self.client.delete_groups(bucket='mozilla') + assert len(deleted_groups) == 0 + def test_collection_creation(self): self.client.create_bucket('mozilla') self.client.create_collection( @@ -235,12 +239,10 @@ def test_collections_deletion(self): self.client.delete_collections(bucket='mozilla') assert len(self.client.get_collections(bucket='mozilla')) == 0 - def test_collections_deletion_if_exists(self): + def test_collections_deletion_when_no_collections_exist(self): self.client.create_bucket('mozilla') - self.client.create_collection('amo', bucket='mozilla') - self.client.create_collection('blocklist', bucket='mozilla') - self.client.delete_collections(bucket='mozilla') - self.client.delete_collections(bucket='mozilla', if_exists=True) + deleted_collections = self.client.delete_collections(bucket='mozilla') + assert len(deleted_collections) == 0 def test_record_creation_and_retrieval(self): client = Client(server_url=self.server_url, auth=self.auth, @@ -356,14 +358,13 @@ def test_multiple_record_deletion(self): client.delete_records() assert len(client.get_records()) == 0 - def test_records_deletion_if_exists(self): + def test_records_deletion_when_no_records_exist(self): client = Client(server_url=self.server_url, auth=self.auth, bucket='mozilla', collection='payments') client.create_bucket() client.create_collection() - client.create_record({'foo': 'bar'}) - client.delete_records() - client.delete_records(if_exists=True) + deleted_records = client.delete_records() + assert len(deleted_records) == 0 def test_bucket_sharing(self): alice_credentials = ('alice', 'p4ssw0rd')