Skip to content
49 changes: 45 additions & 4 deletions sdk/tables/azure-data-tables/azure/data/tables/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def __init__(self, **kwargs): # pylint: disable=super-init-not-called
self.expiry = kwargs.get('expiry')
self.permission = kwargs.get('permission')

def __repr__(self):
# type: () -> str
return "TableAccessPolicy(start={}, expiry={}, permission={})".format(
self.start, self.expiry, self.permission
)[1024:]


class TableAnalyticsLogging(GeneratedLogging):
"""Azure Analytics Logging settings.
Expand Down Expand Up @@ -114,6 +120,12 @@ def _from_generated(cls, generated):
)
)

def __repr__(self):
# type: () -> str
return "TableAnalyticsLogging(version={}, delete={}, read={}, write={}, retention_policy={})".format(
self.version, self.delete, self.read, self.write, self.retention_policy
)[1024:]


class TableMetrics(GeneratedMetrics):
"""A summary of request statistics grouped by API in hour or minute aggregates.
Expand Down Expand Up @@ -153,6 +165,12 @@ def _from_generated(cls, generated):
)
)

def __repr__(self):
# type: () -> str
return "TableMetrics(version={}, enabled={}, include_apis={}, retention_policy={})".format(
self.version, self.enabled, self.include_apis, self.retention_policy
)[1024:]


class TableRetentionPolicy(GeneratedRetentionPolicy):
def __init__(self, **kwargs): # pylint: disable=super-init-not-called
Expand Down Expand Up @@ -190,6 +208,9 @@ def _from_generated(cls, generated, **kwargs): # pylint: disable=unused-argumen
enabled=generated.enabled,
days=generated.days,
)
def __repr__(self):
# type; () -> str
return "TableRetentionPolicy(enabled={}, days={})".format(self.enabled, self.days)[1024:]


class TableCorsRule(object):
Expand Down Expand Up @@ -256,6 +277,12 @@ def _from_generated(cls, generated):
max_age_in_seconds=generated.max_age_in_seconds,
)

def __repr__(self):
# type: () -> str
return "TableCorsRules(allowed_origins={}, allowed_methods={}, allowed_headers={}, exposed_headers={}, max_age_in_seconds={})".format( # pylint: disable=line-too-long
self.allowed_origins, self.allowed_methods, self.allowed_headers, self.exposed_headers, self.max_age_in_seconds # pylint: disable=line-too-long
)[1024:]


class TablePropertiesPaged(PageIterator):
"""An iterable of Table properties.
Expand Down Expand Up @@ -400,6 +427,12 @@ def __str__(self):
+ ("d" if self.delete else "")
)

def __repr__(self):
# type: () -> str
return "TableSasPermissions(read={}, add={}, update={}, delete={})".format(
self.read, self.add, self.update, self.delete
)[1024:]

@classmethod
def from_string(
cls,
Expand Down Expand Up @@ -481,6 +514,10 @@ def _from_generated(cls, generated, **kwargs): # pylint: disable=unused-argumen
# type: (TableQueryResponse, Any) -> TableItem
return cls(generated.table_name) # type: ignore

def __repr__(self):
# type: () -> str
return "TableItem(name={})".format(self.name)[1024:]


class TablePayloadFormat(object):
"""
Expand Down Expand Up @@ -545,8 +582,9 @@ def __init__(self, **kwargs):
self.object = kwargs.get('object', False)
self._str = ("s" if self.service else "") + ("o" if self.object else "")

def __str__(self):
return self._str
def __repr__(self):
# type: () -> str
return "ResourceTypes(service={}, object={})".format(self.service, self.object)[1024:]

@classmethod
def from_string(cls, string):
Expand Down Expand Up @@ -616,8 +654,11 @@ def __init__(self, **kwargs):
+ ("p" if self.process else "")
)

def __str__(self):
return self._str
def __repr__(self):
# type: () -> str
return "AccountSasPermissions(read={}, write={}, delete={}, list={}, add={}, create={}, update={}, process={})".format( # pylint: disable=line-too-long
self.read, self.write, self.delete, self.list, self.add, self.create, self.update, self.process
)[1024:]

@classmethod
def from_string(cls, permission, **kwargs):
Expand Down
3 changes: 2 additions & 1 deletion sdk/tables/azure-data-tables/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def test_set_table_acl_with_empty_signed_identifier(self, tables_storage_account
self._assert_policy_datetime(dt, acl['full'].start)

signed_identifiers.pop('empty')
signed_identifiers['partial'] = None
signed_identifiers['partial'] = None

table.set_table_access_policy(signed_identifiers)
acl = table.get_table_access_policy()
Expand Down Expand Up @@ -397,6 +397,7 @@ def test_set_table_acl_too_many_ids(self, tables_storage_account_name, tables_pr
finally:
ts.delete_table(table.table_name)

@pytest.mark.live_test_only
@tables_decorator
def test_account_sas(self, tables_storage_account_name, tables_primary_storage_account_key):
account_url = self.account_url(tables_storage_account_name, "table")
Expand Down
3 changes: 2 additions & 1 deletion sdk/tables/azure-data-tables/tests/test_table_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async def test_set_table_acl_with_empty_signed_identifier(self, tables_storage_a
self._assert_policy_datetime(dt, acl['full'].start)

signed_identifiers.pop('empty')
signed_identifiers['partial'] = None
signed_identifiers['partial'] = None

await table.set_table_access_policy(signed_identifiers)
acl = await table.get_table_access_policy()
Expand Down Expand Up @@ -338,6 +338,7 @@ async def test_set_table_acl_too_many_ids(self, tables_storage_account_name, tab
finally:
await ts.delete_table(table.table_name)

@pytest.mark.live_test_only
@tables_decorator_async
async def test_account_sas(self, tables_storage_account_name, tables_primary_storage_account_key):
account_url = self.account_url(tables_storage_account_name, "table")
Expand Down