def test_aad_access_policy_error(self, tables_storage_account_name): account_url = self.account_url(tables_storage_account_name, "table") table_name = self._get_table_reference() table_client = TableClient(credential=self.get_token_credential(), endpoint=account_url, table_name=table_name) with pytest.raises(HttpResponseError): table_client.get_table_access_policy() with pytest.raises(HttpResponseError): table_client.set_table_access_policy(signed_identifiers={})
def test_table_name_errors(self, tables_storage_account_name, tables_primary_storage_account_key): endpoint = self.account_url(tables_storage_account_name, "table") # storage table names must be alphanumeric, cannot begin with a number, and must be between 3 and 63 chars long. invalid_table_names = ["1table", "a" * 2, "a" * 64, "a//", "my_table"] for invalid_name in invalid_table_names: client = TableClient(endpoint=endpoint, credential=tables_primary_storage_account_key, table_name=invalid_name) with pytest.raises(ValueError) as error: client.create_table() assert 'Storage table names must be alphanumeric' in str( error.value) with pytest.raises(ValueError) as error: client.create_entity({'PartitionKey': 'foo', 'RowKey': 'bar'}) assert 'Storage table names must be alphanumeric' in str( error.value) with pytest.raises(ValueError) as error: client.upsert_entity({'PartitionKey': 'foo', 'RowKey': 'foo'}) assert 'Storage table names must be alphanumeric' in str( error.value) with pytest.raises(ValueError) as error: client.delete_entity("PK", "RK") assert 'Storage table names must be alphanumeric' in str( error.value) with pytest.raises(ValueError) as error: client.get_table_access_policy() assert 'Storage table names must be alphanumeric' in str( error.value) with pytest.raises(ValueError): batch = [] batch.append(('upsert', {'PartitionKey': 'A', 'RowKey': 'B'})) client.submit_transaction(batch) assert 'Storage table names must be alphanumeric' in str( error.value)