Skip to content

Commit

Permalink
commenting out analytical storage unit tests out until we have emulat…
Browse files Browse the repository at this point in the history
…or support
  • Loading branch information
toswedlu committed Jul 20, 2020
1 parent 72982ce commit 9be5c43
Showing 1 changed file with 64 additions and 63 deletions.
127 changes: 64 additions & 63 deletions sdk/cosmos/azure-cosmos/test/test_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2605,69 +2605,70 @@ def test_get_resource_with_dictionary_and_object(self):
read_permission = created_user.get_permission(created_permission.properties)
self.assertEqual(read_permission.id, created_permission.id)

def test_create_container_with_analytical_store_off(self):
# don't run test, for the time being, if running against the emulator
if 'localhost' in self.host or '127.0.0.1' in self.host:
return

created_db = self.databaseForTest
collection_id = 'test_create_container_with_analytical_store_off_' + str(uuid.uuid4())
collection_indexing_policy = {'indexingMode': 'consistent'}
created_recorder = RecordDiagnostics()
created_collection = created_db.create_container(id=collection_id,
indexing_policy=collection_indexing_policy,
partition_key=PartitionKey(path="/pk", kind="Hash"),
response_hook=created_recorder)
properties = created_collection.read()
ttl_key = "analyticalStorageTtl"
self.assertTrue(ttl_key not in properties or properties[ttl_key] == None)

def test_create_container_with_analytical_store_on(self):
# don't run test, for the time being, if running against the emulator
if 'localhost' in self.host or '127.0.0.1' in self.host:
return

created_db = self.databaseForTest
collection_id = 'test_create_container_with_analytical_store_on_' + str(uuid.uuid4())
collection_indexing_policy = {'indexingMode': 'consistent'}
created_recorder = RecordDiagnostics()
created_collection = created_db.create_container(id=collection_id,
analytical_storage_ttl=-1,
indexing_policy=collection_indexing_policy,
partition_key=PartitionKey(path="/pk", kind="Hash"),
response_hook=created_recorder)
properties = created_collection.read()
ttl_key = "analyticalStorageTtl"
self.assertTrue(ttl_key in properties and properties[ttl_key] == -1)

def test_create_container_if_not_exists_with_analytical_store_on(self):
# don't run test, for the time being, if running against the emulator
if 'localhost' in self.host or '127.0.0.1' in self.host:
return

# first, try when we know the container doesn't exist.
created_db = self.databaseForTest
collection_id = 'test_create_container_if_not_exists_with_analytical_store_on_' + str(uuid.uuid4())
collection_indexing_policy = {'indexingMode': 'consistent'}
created_recorder = RecordDiagnostics()
created_collection = created_db.create_container_if_not_exists(id=collection_id,
analytical_storage_ttl=-1,
indexing_policy=collection_indexing_policy,
partition_key=PartitionKey(path="/pk", kind="Hash"),
response_hook=created_recorder)
properties = created_collection.read()
ttl_key = "analyticalStorageTtl"
self.assertTrue(ttl_key in properties and properties[ttl_key] == -1)

# next, try when we know the container DOES exist. This way both code paths are tested.
created_collection = created_db.create_container_if_not_exists(id=collection_id,
analytical_storage_ttl=-1,
indexing_policy=collection_indexing_policy,
partition_key=PartitionKey(path="/pk", kind="Hash"),
response_hook=created_recorder)
properties = created_collection.read()
ttl_key = "analyticalStorageTtl"
self.assertTrue(ttl_key in properties and properties[ttl_key] == -1)
# Temporarily commenting analytical storage tests until emulator support comes.
# def test_create_container_with_analytical_store_off(self):
# # don't run test, for the time being, if running against the emulator
# if 'localhost' in self.host or '127.0.0.1' in self.host:
# return

# created_db = self.databaseForTest
# collection_id = 'test_create_container_with_analytical_store_off_' + str(uuid.uuid4())
# collection_indexing_policy = {'indexingMode': 'consistent'}
# created_recorder = RecordDiagnostics()
# created_collection = created_db.create_container(id=collection_id,
# indexing_policy=collection_indexing_policy,
# partition_key=PartitionKey(path="/pk", kind="Hash"),
# response_hook=created_recorder)
# properties = created_collection.read()
# ttl_key = "analyticalStorageTtl"
# self.assertTrue(ttl_key not in properties or properties[ttl_key] == None)

# def test_create_container_with_analytical_store_on(self):
# # don't run test, for the time being, if running against the emulator
# if 'localhost' in self.host or '127.0.0.1' in self.host:
# return

# created_db = self.databaseForTest
# collection_id = 'test_create_container_with_analytical_store_on_' + str(uuid.uuid4())
# collection_indexing_policy = {'indexingMode': 'consistent'}
# created_recorder = RecordDiagnostics()
# created_collection = created_db.create_container(id=collection_id,
# analytical_storage_ttl=-1,
# indexing_policy=collection_indexing_policy,
# partition_key=PartitionKey(path="/pk", kind="Hash"),
# response_hook=created_recorder)
# properties = created_collection.read()
# ttl_key = "analyticalStorageTtl"
# self.assertTrue(ttl_key in properties and properties[ttl_key] == -1)

# def test_create_container_if_not_exists_with_analytical_store_on(self):
# # don't run test, for the time being, if running against the emulator
# if 'localhost' in self.host or '127.0.0.1' in self.host:
# return

# # first, try when we know the container doesn't exist.
# created_db = self.databaseForTest
# collection_id = 'test_create_container_if_not_exists_with_analytical_store_on_' + str(uuid.uuid4())
# collection_indexing_policy = {'indexingMode': 'consistent'}
# created_recorder = RecordDiagnostics()
# created_collection = created_db.create_container_if_not_exists(id=collection_id,
# analytical_storage_ttl=-1,
# indexing_policy=collection_indexing_policy,
# partition_key=PartitionKey(path="/pk", kind="Hash"),
# response_hook=created_recorder)
# properties = created_collection.read()
# ttl_key = "analyticalStorageTtl"
# self.assertTrue(ttl_key in properties and properties[ttl_key] == -1)

# # next, try when we know the container DOES exist. This way both code paths are tested.
# created_collection = created_db.create_container_if_not_exists(id=collection_id,
# analytical_storage_ttl=-1,
# indexing_policy=collection_indexing_policy,
# partition_key=PartitionKey(path="/pk", kind="Hash"),
# response_hook=created_recorder)
# properties = created_collection.read()
# ttl_key = "analyticalStorageTtl"
# self.assertTrue(ttl_key in properties and properties[ttl_key] == -1)

def _MockExecuteFunction(self, function, *args, **kwargs):
self.last_headers.append(args[4].headers[HttpHeaders.PartitionKey]
Expand Down

0 comments on commit 9be5c43

Please sign in to comment.