Skip to content

Commit

Permalink
update provider tests to use test_id prefix too
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ11teen committed May 16, 2021
1 parent 608aa4d commit 4fa6632
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions tests/tests/1_storageproviders.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,46 @@ def test_create_if_not_exists(self, storage_provider):
assert storage_provider.create_if_not_exists() == False
assert storage_provider.create_if_not_exists() == True

def test_data_is_stored(self, storage_provider):
etag = storage_provider.upload_data("key1", None, b"data")
data = storage_provider.download_data("key1", etag)
def test_data_is_stored(self, storage_provider, test_id):
key = test_id + "-data-store-test"

etag = storage_provider.upload_data(key, None, b"data")
data = storage_provider.download_data(key, etag)

assert data == b"data"

def test_keys_and_etags_are_listed(self, storage_provider):
etag_3 = storage_provider.upload_data("key3", None, b"data")
etag_4 = storage_provider.upload_data("key4", None, b"data")
def test_keys_and_etags_are_listed(self, storage_provider, test_id):
key_1 = test_id + "-keys-and-etags-list-test-1"
key_2 = test_id + "-keys-and-etags-list-test-2"

etag_1 = storage_provider.upload_data(key_1, None, b"data")
etag_2 = storage_provider.upload_data(key_2, None, b"data")
keys_and_etags = storage_provider.list_keys_and_etags(None)

assert "key3" in keys_and_etags
assert "key4" in keys_and_etags
assert etag_3 == keys_and_etags["key3"]
assert etag_4 == keys_and_etags["key4"]
assert key_1 in keys_and_etags
assert key_2 in keys_and_etags
assert etag_1 == keys_and_etags[key_1]
assert etag_2 == keys_and_etags[key_2]

def test_keys_are_deleted(self, storage_provider, test_id):
key = test_id + "-keys-deleted-test"

etag = storage_provider.upload_data(key, None, b"data")
storage_provider.delete_data(key, etag)

def test_keys_are_deleted(self, storage_provider):
etag = storage_provider.upload_data("key5", None, b"data")
storage_provider.delete_data("key5", etag)
cloud_key_list = storage_provider.list_keys_and_etags(key)
assert key not in cloud_key_list

cloud_key_list = storage_provider.list_keys_and_etags("key5")
assert "key5" not in cloud_key_list
def test_etags_are_enforced(self, storage_provider, test_id):
key = test_id + "etags-enforced-test"

def test_etags_are_enforced(self, storage_provider):
with pytest.raises(KeySyncError):
storage_provider.upload_data("key6", "etag-when-none-existing", b"data")
storage_provider.upload_data(key, "etag-when-none-existing", b"data")

storage_provider.upload_data("key6", None, b"0")
storage_provider.upload_data(key, None, b"0")
with pytest.raises(KeySyncError):
storage_provider.download_data("key6", "bad-etag")
storage_provider.download_data(key, "bad-etag")
with pytest.raises(KeySyncError):
storage_provider.upload_data("key6", "bad-etag", b"data")
storage_provider.upload_data(key, "bad-etag", b"data")
with pytest.raises(KeySyncError):
storage_provider.delete_data("key6", "bad-etag")
storage_provider.delete_data(key, "bad-etag")

0 comments on commit 4fa6632

Please sign in to comment.