@@ -47,10 +47,10 @@ def callback(response):
47
47
tables = list (service .list_tables (raw_response_hook = callback ))
48
48
assert isinstance (tables , list )
49
49
50
+ # The count doesn't matter, going through the PagedItem calls `callback`
50
51
count = 0
51
52
for table in tables :
52
53
count += 1
53
- assert count == 0
54
54
55
55
def callback (response ):
56
56
assert 'User-Agent' in response .http_request .headers
@@ -62,11 +62,10 @@ def callback(response):
62
62
tables = list (service .list_tables (raw_response_hook = callback , user_agent = "TestApp/v2.0" ))
63
63
assert isinstance (tables , list )
64
64
65
+ # The count doesn't matter, going through the PagedItem calls `callback`
65
66
count = 0
66
67
for table in tables :
67
68
count += 1
68
- assert count == 0
69
-
70
69
71
70
@TablesPreparer ()
72
71
def test_user_agent_append (self , tables_storage_account_name , tables_primary_storage_account_key ):
@@ -79,10 +78,10 @@ def callback(response):
79
78
custom_headers = {'User-Agent' : 'customer_user_agent' }
80
79
tables = service .list_tables (raw_response_hook = callback , headers = custom_headers )
81
80
81
+ # The count doesn't matter, going through the PagedItem calls `callback`
82
82
count = 0
83
83
for table in tables :
84
84
count += 1
85
- assert count == 0
86
85
87
86
@TablesPreparer ()
88
87
def test_user_agent_default (self , tables_storage_account_name , tables_primary_storage_account_key ):
@@ -98,10 +97,10 @@ def callback(response):
98
97
tables = list (service .list_tables (raw_response_hook = callback ))
99
98
assert isinstance (tables , list )
100
99
100
+ # The count doesn't matter, going through the PagedItem calls `callback`
101
101
count = 0
102
102
for table in tables :
103
103
count += 1
104
- assert count == 0
105
104
106
105
107
106
class TestTableUnitTests (TableTestCase ):
@@ -144,16 +143,17 @@ def test_create_service_with_sas(self):
144
143
# Arrange
145
144
url = self .account_url (self .tables_storage_account_name , "table" )
146
145
suffix = '.table.core.windows.net'
146
+ token = self .generate_sas_token ()
147
147
for service_type in SERVICES :
148
148
# Act
149
149
service = service_type (
150
- self .account_url (self .tables_storage_account_name , "table" ), credential = self . generate_sas_token () , table_name = 'foo' )
150
+ self .account_url (self .tables_storage_account_name , "table" ), credential = token , table_name = 'foo' )
151
151
152
152
# Assert
153
153
assert service is not None
154
154
assert service .account_name == self .tables_storage_account_name
155
155
assert service .url .startswith ('https://' + self .tables_storage_account_name + suffix )
156
- assert service .url .endswith (self . generate_sas_token () )
156
+ assert service .url .endswith (token )
157
157
assert service .credential is None
158
158
159
159
def test_create_service_china (self ):
@@ -230,7 +230,9 @@ def test_create_service_with_connection_string_key(self):
230
230
231
231
def test_create_service_with_connection_string_sas (self ):
232
232
# Arrange
233
- conn_string = 'AccountName={};SharedAccessSignature={};' .format (self .tables_storage_account_name , self .generate_sas_token ())
233
+ token = self .generate_sas_token ()
234
+ conn_string = 'AccountName={};SharedAccessSignature={};' .format (
235
+ self .tables_storage_account_name , token )
234
236
235
237
for service_type in SERVICES :
236
238
# Act
@@ -239,8 +241,9 @@ def test_create_service_with_connection_string_sas(self):
239
241
# Assert
240
242
assert service is not None
241
243
assert service .account_name == self .tables_storage_account_name
242
- assert service .url .startswith ('https://' + self .tables_storage_account_name + '.table.core.windows.net' )
243
- assert service .url .endswith (self .generate_sas_token ())
244
+ assert service .url .startswith (
245
+ 'https://' + self .tables_storage_account_name + '.table.core.windows.net' )
246
+ assert service .url .endswith (token )
244
247
assert service .credential is None
245
248
246
249
def test_create_service_with_connection_string_cosmos (self ):
@@ -369,7 +372,8 @@ def test_create_service_with_conn_str_succeeds_if_sec_with_primary(self):
369
372
assert service ._primary_endpoint .startswith ('https://www.mydomain.com' )
370
373
371
374
def test_create_service_with_custom_account_endpoint_path (self ):
372
- custom_account_url = "http://local-machine:11002/custom/account/path/" + self .generate_sas_token ()
375
+ token = self .generate_sas_token ()
376
+ custom_account_url = "http://local-machine:11002/custom/account/path/" + token
373
377
for service_type in SERVICES .items ():
374
378
conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};TableEndpoint={};' .format (
375
379
self .tables_storage_account_name , self .tables_primary_storage_account_key , custom_account_url )
@@ -396,7 +400,7 @@ def test_create_service_with_custom_account_endpoint_path(self):
396
400
assert service ._primary_hostname == 'local-machine:11002/custom/account/path'
397
401
assert service .url .startswith ('http://local-machine:11002/custom/account/path' )
398
402
399
- service = TableClient .from_table_url ("http://local-machine:11002/custom/account/path/foo" + self . generate_sas_token () )
403
+ service = TableClient .from_table_url ("http://local-machine:11002/custom/account/path/foo" + token )
400
404
assert service .account_name == None
401
405
assert service .table_name == "foo"
402
406
assert service .credential == None
0 commit comments