Example #1
0
 async def test_table_name_errors_bad_chars(self, tables_cosmos_account_name, tables_primary_cosmos_account_key):
     endpoint = self.account_url(tables_cosmos_account_name, "cosmos")
     
     # cosmos table names must be a non-empty string without chars '\', '/', '#', '?', and less than 255 chars.
     invalid_table_names = ["\\", "//", "#", "?", "- "]
     for invalid_name in invalid_table_names:
         client = TableClient(
             endpoint=endpoint, credential=tables_primary_cosmos_account_key, table_name=invalid_name)
         async with client:
             with pytest.raises(ValueError) as error:
                 await client.create_table()
             assert "Cosmos table names must contain from 1-255 characters" in str(error.value)
             try:
                 with pytest.raises(ValueError) as error:
                     await client.delete_table()
                 assert "Cosmos table names must contain from 1-255 characters" in str(error.value)
             except HttpResponseError as error:
                 # Delete table returns a MethodNotAllowed for tablename == "\"
                 if error.error_code != 'MethodNotAllowed':
                     raise
             with pytest.raises(ValueError) as error:
                 await client.create_entity({'PartitionKey': 'foo', 'RowKey': 'foo'})
             assert "Cosmos table names must contain from 1-255 characters" in str(error.value)
             with pytest.raises(ValueError) as error:
                 await client.upsert_entity({'PartitionKey': 'foo', 'RowKey': 'foo'})
             assert "Cosmos table names must contain from 1-255 characters" in str(error.value)
             with pytest.raises(ValueError) as error:
                 await client.delete_entity("PK", "RK")
             assert "Cosmos table names must contain from 1-255 characters" in str(error.value)
             with pytest.raises(ValueError) as error:
                 batch = []
                 batch.append(('upsert', {'PartitionKey': 'A', 'RowKey': 'B'}))
                 await client.submit_transaction(batch)
             assert "Cosmos table names must contain from 1-255 characters" in str(error.value)
Example #2
0
    async def test_create_service_with_custom_account_endpoint_path_async(self):
        token = self.generate_sas_token()
        custom_account_url = "http://local-machine:11002/custom/account/path/" + token
        for service_type in SERVICES.items():
            conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};TableEndpoint={};'.format(
                self.tables_storage_account_name, self.tables_primary_storage_account_key, custom_account_url)

            # Act
            service = service_type[0].from_connection_string(conn_string, table_name="foo")

            # Assert
            assert service.account_name ==  self.tables_storage_account_name
            assert service.credential.account_name ==  self.tables_storage_account_name
            assert service.credential.account_key ==  self.tables_primary_storage_account_key
            assert service._primary_hostname ==  'local-machine:11002/custom/account/path'

        service = TableServiceClient(account_url=custom_account_url)
        assert service.account_name == "custom"
        assert service.credential ==  None
        assert service._primary_hostname ==  'local-machine:11002/custom/account/path'
        assert service.url.startswith('http://local-machine:11002/custom/account/path')

        service = TableClient(account_url=custom_account_url, table_name="foo")
        assert service.account_name == "custom"
        assert service.table_name ==  "foo"
        assert service.credential ==  None
        assert service._primary_hostname ==  'local-machine:11002/custom/account/path'
        assert service.url.startswith('http://local-machine:11002/custom/account/path')

        service = TableClient.from_table_url("http://local-machine:11002/custom/account/path/foo" + token)
        assert service.account_name == "custom"
        assert service.table_name ==  "foo"
        assert service.credential ==  None
        assert service._primary_hostname ==  'local-machine:11002/custom/account/path'
        assert service.url.startswith('http://local-machine:11002/custom/account/path')
    async def test_create_service_with_custom_account_endpoint_path_async(self, resource_group, location, cosmos_account, cosmos_account_key):
        custom_account_url = "http://local-machine:11002/custom/account/path/" + self.sas_token
        for service_type in SERVICES.items():
            conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};TableEndpoint={};'.format(
                cosmos_account.name, cosmos_account_key, custom_account_url)

            # Act
            service = service_type[0].from_connection_string(conn_string, table_name="foo")

            # Assert
            assert service.account_name ==  cosmos_account.name
            assert service.credential.account_name ==  cosmos_account.name
            assert service.credential.account_key ==  cosmos_account_key
            assert service._primary_hostname ==  'local-machine:11002/custom/account/path'

        service = TableServiceClient(account_url=custom_account_url)
        assert service.account_name ==  None
        assert service.credential ==  None
        assert service._primary_hostname ==  'local-machine:11002/custom/account/path'
        # mine doesnt have a question mark at the end
        assert service.url.startswith('http://local-machine:11002/custom/account/path')

        service = TableClient(account_url=custom_account_url, table_name="foo")
        assert service.account_name ==  None
        assert service.table_name ==  "foo"
        assert service.credential ==  None
        assert service._primary_hostname ==  'local-machine:11002/custom/account/path'
        assert service.url.startswith('http://local-machine:11002/custom/account/path')

        service = TableClient.from_table_url("http://local-machine:11002/custom/account/path/foo" + self.sas_token)
        assert service.account_name ==  None
        assert service.table_name ==  "foo"
        assert service.credential ==  None
        assert service._primary_hostname ==  'local-machine:11002/custom/account/path'
        assert service.url.startswith('http://local-machine:11002/custom/account/path')
    async def test_create_service_with_custom_account_endpoint_path_async(self, resource_group, location, storage_account, storage_account_key):
        custom_account_url = "http://local-machine:11002/custom/account/path/" + self.sas_token
        for service_type in SERVICES.items():
            conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};TableEndpoint={};'.format(
                storage_account.name, storage_account_key, custom_account_url)

            # Act
            service = service_type[0].from_connection_string(conn_string, table_name="foo")

            # Assert
            self.assertEqual(service.account_name, storage_account.name)
            self.assertEqual(service.credential.account_name, storage_account.name)
            self.assertEqual(service.credential.account_key, storage_account_key)
            self.assertEqual(service._primary_hostname, 'local-machine:11002/custom/account/path')

        service = TableServiceClient(account_url=custom_account_url)
        self.assertEqual(service.account_name, None)
        self.assertEqual(service.credential, None)
        self.assertEqual(service._primary_hostname, 'local-machine:11002/custom/account/path')
        self.assertTrue(service.url.startswith('http://local-machine:11002/custom/account/path'))

        service = TableClient(account_url=custom_account_url, table_name="foo")
        self.assertEqual(service.account_name, None)
        self.assertEqual(service.table_name, "foo")
        self.assertEqual(service.credential, None)
        self.assertEqual(service._primary_hostname, 'local-machine:11002/custom/account/path')
        self.assertTrue(service.url.startswith('http://local-machine:11002/custom/account/path'))

        service = TableClient.from_table_url("http://local-machine:11002/custom/account/path/foo" + self.sas_token)
        self.assertEqual(service.account_name, None)
        self.assertEqual(service.table_name, "foo")
        self.assertEqual(service.credential, None)
        self.assertEqual(service._primary_hostname, 'local-machine:11002/custom/account/path')
        self.assertTrue(service.url.startswith('http://local-machine:11002/custom/account/path'))
Example #5
0
    async 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)
            async with client:
                with pytest.raises(ValueError) as error:
                    await client.create_table()
                assert 'Storage table names must be alphanumeric' in str(error.value)
                with pytest.raises(ValueError) as error:
                    await client.create_entity({'PartitionKey': 'foo', 'RowKey': 'bar'})
                assert 'Storage table names must be alphanumeric' in str(error.value)
                with pytest.raises(ValueError) as error:
                    await client.upsert_entity({'PartitionKey': 'foo', 'RowKey': 'foo'})
                assert 'Storage table names must be alphanumeric' in str(error.value)
                with pytest.raises(ValueError) as error:
                    await client.delete_entity("PK", "RK")
                assert 'Storage table names must be alphanumeric' in str(error.value)
                with pytest.raises(ValueError) as error:
                    await client.get_table_access_policy()
                assert 'Storage table names must be alphanumeric' in str(error.value)
                with pytest.raises(ValueError) as error:
                    batch = []
                    batch.append(('upsert', {'PartitionKey': 'A', 'RowKey': 'B'}))
                    await client.submit_transaction(batch)
                assert 'Storage table names must be alphanumeric' in str(error.value)
Example #6
0
    async def delete_entity(self):
        from azure.data.tables.aio import TableClient
        from azure.core.exceptions import ResourceNotFoundError, ResourceExistsError
        from azure.core.credentials import AzureNamedKeyCredential

        credential = AzureNamedKeyCredential(self.account_name,
                                             self.access_key)
        table_client = TableClient(account_url=self.account_url,
                                   credential=credential,
                                   table_name=self.table_name)

        # [START delete_entity]
        async with table_client:
            try:
                resp = await table_client.create_entity(entity=self.entity)
            except ResourceExistsError:
                print("Entity already exists!")

            try:
                await table_client.delete_entity(
                    row_key=self.entity["RowKey"],
                    partition_key=self.entity["PartitionKey"])
                print("Successfully deleted!")
            except ResourceNotFoundError:
                print("Entity does not exists")
    async def test_create_table_client_with_complete_url_async(self, resource_group, location, storage_account, storage_account_key):
        # Arrange
        table_url = "https://{}.table.core.windows.net:443/foo".format(storage_account.name)
        service = TableClient(account_url=table_url, table_name='bar', credential=storage_account_key)

        # Assert
        self.assertEqual(service.scheme, 'https')
        self.assertEqual(service.table_name, 'bar')
        self.assertEqual(service.account_name, storage_account.name)
    async def test_create_table_client_with_complete_table_url_async(self, resource_group, location, storage_account, storage_account_key):
        # Arrange
        table_url = self.account_url(storage_account, "table") + "/foo"
        service = TableClient(table_url, table_name='bar', credential=storage_account_key)

        # Assert
        self.assertEqual(service.scheme, 'https')
        self.assertEqual(service.table_name, 'bar')
        self.assertEqual(service.account_name, storage_account.name)
Example #9
0
    async def test_create_table_client_with_complete_table_url_async(self):
        # Arrange
        table_url = self.account_url(self.tables_storage_account_name, "table") + "/foo"
        service = TableClient(table_url, table_name='bar', credential=self.credential)

        # Assert
        assert service.scheme == 'https'
        assert service.table_name == 'bar'
        assert service.account_name == self.tables_storage_account_name
Example #10
0
    async def test_create_table_client_with_complete_url_async(self):
        # Arrange
        table_url = "https://{}.table.core.windows.net:443/foo".format(self.tables_storage_account_name)
        service = TableClient(endpoint=table_url, table_name='bar', credential=self.credential)

        # Assert
        assert service.scheme == 'https'
        assert service.table_name == 'bar'
        assert service.account_name == self.tables_storage_account_name
    async def test_create_table_client_with_complete_table_url_async(self, resource_group, location, cosmos_account, cosmos_account_key):
        # Arrange
        table_url = self.account_url(cosmos_account, "cosmos") + "/foo"
        service = TableClient(table_url, table_name='bar', credential=cosmos_account_key)

        # Assert
        assert service.scheme ==  'https'
        assert service.table_name ==  'bar'
        assert service.account_name ==  cosmos_account.name
Example #12
0
    async def test_create_table_client_with_complete_url_async(self):
        # Arrange
        table_url = "https://{}.table.cosmos.azure.com:443/foo".format(self.tables_cosmos_account_name)
        service = TableClient(table_url, table_name='bar', credential=self.credential)

        # Assert
        assert service.scheme ==  'https'
        assert service.table_name ==  'bar'
        assert service.account_name ==  self.tables_cosmos_account_name
    async def test_create_table_client_with_complete_url_async(self, resource_group, location, cosmos_account, cosmos_account_key):
        # Arrange
        table_url = "https://{}.table.cosmos.azure.com:443/foo".format(cosmos_account.name)
        service = TableClient(table_url, table_name='bar', credential=cosmos_account_key)

        # Assert
        assert service.scheme ==  'https'
        assert service.table_name ==  'bar'
        assert service.account_name ==  cosmos_account.name
Example #14
0
    async def test_create_table_client_with_invalid_name_async(self):
        # Arrange
        table_url = "https://{}.table.core.windows.net:443/foo".format("storage_account_name")
        invalid_table_name = "my_table"

        # Assert
        with pytest.raises(ValueError) as excinfo:
            service = TableClient(endpoint=table_url, table_name=invalid_table_name, credential="self.tables_primary_storage_account_key")

        assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long."in str(excinfo)
    async def test_create_table_client_with_invalid_name_async(self):
        # Arrange
        table_url = "https://{}.table.cosmos.azure.com:443/foo".format("cosmos_account_name")
        invalid_table_name = "my_table"

        # Assert
        with pytest.raises(ValueError) as excinfo:
            service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="cosmos_account_key")

        assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long.""" in str(excinfo)
Example #16
0
    async 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):
            await table_client.get_table_access_policy()

        with pytest.raises(HttpResponseError):
            await table_client.set_table_access_policy(signed_identifiers={})
    async def test_create_table_client_with_complete_table_url_async(self):
        # Arrange
        table_url = self.account_url(self.tables_cosmos_account_name,
                                     "cosmos") + "/foo"
        service = TableClient(
            table_url,
            table_name='bar',
            credential=self.tables_primary_cosmos_account_key)

        # Assert
        assert service.scheme == 'https'
        assert service.table_name == 'bar'
        assert service.account_name == self.tables_cosmos_account_name
Example #18
0
    def test_create_client_for_cosmos_emulator(self):
        emulator_credential = AzureNamedKeyCredential(
            'localhost', self.tables_primary_cosmos_account_key)
        emulator_connstr = "DefaultEndpointsProtocol=http;AccountName=localhost;AccountKey={};TableEndpoint=http://localhost:8902/;".format(
            self.tables_primary_cosmos_account_key)

        client = TableServiceClient.from_connection_string(emulator_connstr)
        assert client.url == "http://localhost:8902"
        assert client.account_name == 'localhost'
        assert client.credential.named_key.name == 'localhost'
        assert client.credential.named_key.key == self.tables_primary_cosmos_account_key
        assert client._cosmos_endpoint

        client = TableServiceClient("http://localhost:8902/",
                                    credential=emulator_credential)
        assert client.url == "http://localhost:8902"
        assert client.account_name == 'localhost'
        assert client.credential.named_key.name == 'localhost'
        assert client.credential.named_key.key == self.tables_primary_cosmos_account_key
        assert client._cosmos_endpoint

        table = TableClient.from_connection_string(emulator_connstr,
                                                   'tablename')
        assert table.url == "http://localhost:8902"
        assert table.account_name == 'localhost'
        assert table.table_name == 'tablename'
        assert table.credential.named_key.name == 'localhost'
        assert table.credential.named_key.key == self.tables_primary_cosmos_account_key
        assert table._cosmos_endpoint

        table = TableClient("http://localhost:8902/",
                            "tablename",
                            credential=emulator_credential)
        assert table.url == "http://localhost:8902"
        assert table.account_name == 'localhost'
        assert table.table_name == 'tablename'
        assert table.credential.named_key.name == 'localhost'
        assert table.credential.named_key.key == self.tables_primary_cosmos_account_key
        assert table._cosmos_endpoint

        table = TableClient.from_table_url(
            "http://localhost:8902/Tables('tablename')",
            credential=emulator_credential)
        assert table.url == "http://localhost:8902"
        assert table.account_name == 'localhost'
        assert table.table_name == 'tablename'
        assert table.credential.named_key.name == 'localhost'
        assert table.credential.named_key.key == self.tables_primary_cosmos_account_key
        assert table._cosmos_endpoint
Example #19
0
    async def test_create_table_client_with_invalid_name_async(
            self, resource_group, location, storage_account,
            storage_account_key):
        # Arrange
        table_url = "https://{}.table.core.windows.net:443/foo".format(
            storage_account.name)
        invalid_table_name = "my_table"

        # Assert
        with pytest.raises(ValueError) as excinfo:
            service = TableClient(account_url=table_url,
                                  table_name=invalid_table_name,
                                  credential=storage_account_key)

        assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long." "" in str(
            excinfo)
Example #20
0
    async def test_create_service_with_custom_account_endpoint_path_async(
            self):
        self.sas_token = self.generate_sas_token()
        self.sas_token = AzureSasCredential(self.sas_token)
        custom_account_url = "http://local-machine:11002/custom/account/path/" + self.sas_token.signature
        for service_type in SERVICES.items():
            conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};TableEndpoint={};'.format(
                self.tables_cosmos_account_name,
                self.tables_primary_cosmos_account_key, custom_account_url)

            # Act
            service = service_type[0].from_connection_string(conn_string,
                                                             table_name="foo")

            # Assert
            assert service.account_name == self.tables_cosmos_account_name
            assert service.credential.named_key.name == self.tables_cosmos_account_name
            assert service.credential.named_key.key == self.tables_primary_cosmos_account_key
            assert service._primary_hostname == 'local-machine:11002/custom/account/path'

        service = TableServiceClient(endpoint=custom_account_url)
        assert service.account_name == "custom"
        assert service.credential == None
        assert service._primary_hostname == 'local-machine:11002/custom/account/path'
        # mine doesnt have a question mark at the end
        assert service.url.startswith(
            'http://local-machine:11002/custom/account/path')

        service = TableClient(endpoint=custom_account_url, table_name="foo")
        assert service.account_name == "custom"
        assert service.table_name == "foo"
        assert service.credential == None
        assert service._primary_hostname == 'local-machine:11002/custom/account/path'
        assert service.url.startswith(
            'http://local-machine:11002/custom/account/path')

        service = TableClient.from_table_url(
            "http://local-machine:11002/custom/account/path/foo" +
            self.sas_token.signature)
        assert service.account_name == "custom"
        assert service.table_name == "foo"
        assert service.credential == None
        assert service._primary_hostname == 'local-machine:11002/custom/account/path'
        assert service.url.startswith(
            'http://local-machine:11002/custom/account/path')
Example #21
0
 async def test_table_name_errors_bad_length(self, tables_cosmos_account_name, tables_primary_cosmos_account_key):
     endpoint = self.account_url(tables_cosmos_account_name, "cosmos")
     
     # cosmos table names must be a non-empty string without chars '\', '/', '#', '?', and less than 255 chars.
     client = TableClient(endpoint=endpoint, credential=tables_primary_cosmos_account_key, table_name="-"*255)
     async with client:
         with pytest.raises(ValueError) as error:
             await client.create_table()
         assert "Cosmos table names must contain from 1-255 characters" in str(error.value)
         with pytest.raises(ResourceNotFoundError):
             await client.create_entity({'PartitionKey': 'foo', 'RowKey': 'foo'})
         with pytest.raises(ResourceNotFoundError):
             await client.upsert_entity({'PartitionKey': 'foo', 'RowKey': 'foo'})
         with pytest.raises(TableTransactionError) as error:
             batch = []
             batch.append(('upsert', {'PartitionKey': 'A', 'RowKey': 'B'}))
             await client.submit_transaction(batch)
         assert error.value.error_code == 'ResourceNotFound'
Example #22
0
    async def test_aad_create_table_tc(self, tables_storage_account_name):
        try:
            account_url = self.account_url(tables_storage_account_name,
                                           "table")
            ts = TableServiceClient(credential=self.get_token_credential(),
                                    endpoint=account_url)
            table_name = self._get_table_reference()
            table_client = TableClient(credential=self.get_token_credential(),
                                       endpoint=account_url,
                                       table_name=table_name)
            await table_client.create_table()

            if table_name not in [t.name async for t in ts.list_tables()]:
                raise AssertionError("Table could not be found")

            await table_client.delete_table()
            if table_name in [t.name async for t in ts.list_tables()]:
                raise AssertionError("Table was not deleted")

        finally:
            await ts.delete_table(table_name)
Example #23
0
    async def test_create_client_for_azurite(self):
        azurite_credential = AzureNamedKeyCredential(
            "myaccount", self.tables_primary_storage_account_key)
        http_connstr = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey={};TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;".format(
            self.tables_primary_storage_account_key)
        https_connstr = "DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey={};TableEndpoint=https://127.0.0.1:10002/devstoreaccount1;".format(
            self.tables_primary_storage_account_key)
        account_url = "https://127.0.0.1:10002/myaccount"
        client = TableServiceClient(account_url, credential=azurite_credential)
        assert client.account_name == "myaccount"
        assert client.url == "https://127.0.0.1:10002/myaccount"
        assert client._location_mode == "primary"
        assert client._secondary_endpoint == "https://127.0.0.1:10002/myaccount-secondary"
        assert client.credential.named_key.key == azurite_credential.named_key.key
        assert client.credential.named_key.name == azurite_credential.named_key.name
        assert not client._cosmos_endpoint

        client = TableServiceClient.from_connection_string(http_connstr)
        assert client.account_name == "devstoreaccount1"
        assert client.url == "http://127.0.0.1:10002/devstoreaccount1"
        assert client._location_mode == "primary"
        assert client._secondary_endpoint == "http://127.0.0.1:10002/devstoreaccount1-secondary"
        assert client.credential.named_key.key == self.tables_primary_storage_account_key
        assert client.credential.named_key.name == "devstoreaccount1"
        assert not client._cosmos_endpoint

        client = TableServiceClient.from_connection_string(https_connstr)
        assert client.account_name == "devstoreaccount1"
        assert client.url == "https://127.0.0.1:10002/devstoreaccount1"
        assert client._location_mode == "primary"
        assert client._secondary_endpoint == "https://127.0.0.1:10002/devstoreaccount1-secondary"
        assert client.credential.named_key.key == self.tables_primary_storage_account_key
        assert client.credential.named_key.name == "devstoreaccount1"
        assert not client._cosmos_endpoint

        table = TableClient(account_url,
                            "tablename",
                            credential=azurite_credential)
        assert table.account_name == "myaccount"
        assert table.table_name == "tablename"
        assert table.url == "https://127.0.0.1:10002/myaccount"
        assert table._location_mode == "primary"
        assert table._secondary_endpoint == "https://127.0.0.1:10002/myaccount-secondary"
        assert table.credential.named_key.key == azurite_credential.named_key.key
        assert table.credential.named_key.name == azurite_credential.named_key.name
        assert not table._cosmos_endpoint

        table = TableClient.from_connection_string(http_connstr, "tablename")
        assert table.account_name == "devstoreaccount1"
        assert table.table_name == "tablename"
        assert table.url == "http://127.0.0.1:10002/devstoreaccount1"
        assert table._location_mode == "primary"
        assert table._secondary_endpoint == "http://127.0.0.1:10002/devstoreaccount1-secondary"
        assert table.credential.named_key.key == self.tables_primary_storage_account_key
        assert table.credential.named_key.name == "devstoreaccount1"
        assert not table._cosmos_endpoint

        table = TableClient.from_connection_string(https_connstr, "tablename")
        assert table.account_name == "devstoreaccount1"
        assert table.table_name == "tablename"
        assert table.url == "https://127.0.0.1:10002/devstoreaccount1"
        assert table._location_mode == "primary"
        assert table._secondary_endpoint == "https://127.0.0.1:10002/devstoreaccount1-secondary"
        assert table.credential.named_key.key == self.tables_primary_storage_account_key
        assert table.credential.named_key.name == "devstoreaccount1"
        assert not table._cosmos_endpoint

        table_url = "https://127.0.0.1:10002/myaccount/Tables('tablename')"
        table = TableClient.from_table_url(table_url,
                                           credential=azurite_credential)
        assert table.account_name == "myaccount"
        assert table.table_name == "tablename"
        assert table.url == "https://127.0.0.1:10002/myaccount"
        assert table._location_mode == "primary"
        assert table._secondary_endpoint == "https://127.0.0.1:10002/myaccount-secondary"
        assert table.credential.named_key.key == azurite_credential.named_key.key
        assert table.credential.named_key.name == azurite_credential.named_key.name
        assert not table._cosmos_endpoint