Skip to content

Commit

Permalink
[pylint] Fix pylint issues for azure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshg999 committed Mar 6, 2024
1 parent 1791175 commit 3b60e9a
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions desktop/libs/azure/src/azure/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def test_with_core_site(self):
with patch('azure.conf.core_site.get_conf') as core_site_get_conf:
get_token.return_value = {'access_token': 'access_token', 'token_type': '', 'expires_on': None}
get_conf.return_value = {}
core_site_get_conf.return_value = {'dfs.adls.oauth2.client.id': 'client_id', 'dfs.adls.oauth2.credential': 'client_secret', 'dfs.adls.oauth2.refresh.url': 'refresh_url'}
core_site_get_conf.return_value = {
'dfs.adls.oauth2.client.id': 'client_id',
'dfs.adls.oauth2.credential': 'client_secret',
'dfs.adls.oauth2.refresh.url': 'refresh_url'
}
client1 = get_client(name='default', fs='adl')
client2 = get_client(name='default', fs='adl', user='test')

Expand All @@ -56,8 +60,12 @@ def test_with_core_site(self):

def test_with_credentials(self):
try:
finish = (conf.AZURE_ACCOUNTS.set_for_testing({'default': {'client_id':'client_id', 'client_secret': 'client_secret', 'tenant_id': 'tenant_id'}}),
conf.ADLS_CLUSTERS.set_for_testing({'default': {'fs_defaultfs': 'fs_defaultfs', 'webhdfs_url': 'webhdfs_url'}}))
finish = (
conf.AZURE_ACCOUNTS.set_for_testing({
'default': {'client_id':'client_id', 'client_secret': 'client_secret', 'tenant_id': 'tenant_id'}
}),
conf.ADLS_CLUSTERS.set_for_testing({'default': {'fs_defaultfs': 'fs_defaultfs', 'webhdfs_url': 'webhdfs_url'}})
)
with patch('azure.client.conf_idbroker.get_conf') as get_conf:
with patch('azure.client.WebHdfs.get_client'):
with patch('azure.client.ActiveDirectory.get_token') as get_token:
Expand Down Expand Up @@ -91,7 +99,7 @@ def test_with_idbroker(self):
}
get_cab_address.return_value = 'address'
has_azure_metadata.return_value = True
get_cab.return_value = { 'access_token': 'access_token', 'token_type': 'token_type', 'expires_on': 0 }
get_cab.return_value = {'access_token': 'access_token', 'token_type': 'token_type', 'expires_on': 0}
provider = get_credential_provider('default', 'hue')

assert_equal(provider.get_credentials().get('access_token'), 'access_token')
Expand All @@ -102,7 +110,9 @@ def test_with_idbroker(self):
assert_not_equal(client1, client2) # Test that with Expiration 0 clients not equal

get_cab.return_value = {
'Credentials': {'access_token': 'access_token', 'token_type': 'token_type', 'expires_on': int(current_ms_from_utc()) + 10*1000}
'Credentials': {
'access_token': 'access_token', 'token_type': 'token_type', 'expires_on': int(current_ms_from_utc()) + 10*1000
}
}
client3 = get_client(name='default', fs='adl', user='hue')
client4 = get_client(name='default', fs='adl', user='hue')
Expand All @@ -128,7 +138,11 @@ def test_with_core_site(self):
with patch('azure.conf.core_site.get_conf') as core_site_get_conf:
get_token.return_value = {'access_token': 'access_token', 'token_type': '', 'expires_on': None}
get_conf.return_value = {}
core_site_get_conf.return_value = {'fs.azure.account.oauth2.client.id': 'client_id', 'fs.azure.account.oauth2.client.secret': 'client_secret', 'fs.azure.account.oauth2.client.endpoint': 'refresh_url'}
core_site_get_conf.return_value = {
'fs.azure.account.oauth2.client.id': 'client_id',
'fs.azure.account.oauth2.client.secret': 'client_secret',
'fs.azure.account.oauth2.client.endpoint': 'refresh_url'
}
client1 = get_client(name='default', fs='abfs')
client2 = get_client(name='default', fs='abfs', user='test')

Expand All @@ -143,8 +157,12 @@ def test_with_core_site(self):

def test_with_credentials(self):
try:
finish = (conf.AZURE_ACCOUNTS.set_for_testing({'default': {'client_id':'client_id', 'client_secret': 'client_secret', 'tenant_id': 'tenant_id'}}),
conf.ABFS_CLUSTERS.set_for_testing({'default': {'fs_defaultfs': 'fs_defaultfs', 'webhdfs_url': 'webhdfs_url'}}))
finish = (
conf.AZURE_ACCOUNTS.set_for_testing({
'default': {'client_id': 'client_id', 'client_secret': 'client_secret', 'tenant_id': 'tenant_id'}
}),
conf.ABFS_CLUSTERS.set_for_testing({'default': {'fs_defaultfs': 'fs_defaultfs', 'webhdfs_url': 'webhdfs_url'}})
)
with patch('azure.client.conf_idbroker.get_conf') as get_conf:
with patch('azure.client.ABFS.get_client'):
with patch('azure.client.ActiveDirectory.get_token') as get_token:
Expand Down Expand Up @@ -178,7 +196,7 @@ def test_with_idbroker(self):
}
get_cab_address.return_value = 'address'
has_azure_metadata.return_value = True
get_cab.return_value = { 'access_token': 'access_token', 'token_type': 'token_type', 'expires_on': 0 }
get_cab.return_value = {'access_token': 'access_token', 'token_type': 'token_type', 'expires_on': 0}
provider = get_credential_provider('default', 'hue')

assert_equal(provider.get_credentials().get('access_token'), 'access_token')
Expand All @@ -189,7 +207,9 @@ def test_with_idbroker(self):
assert_not_equal(client1, client2) # Test that with Expiration 0 clients not equal

get_cab.return_value = {
'Credentials': {'access_token': 'access_token', 'token_type': 'token_type', 'expires_on': int(current_ms_from_utc()) + 10*1000}
'Credentials': {
'access_token': 'access_token', 'token_type': 'token_type', 'expires_on': int(current_ms_from_utc()) + 10*1000
}
}
client3 = get_client(name='default', fs='abfs', user='hue')
client4 = get_client(name='default', fs='abfs', user='hue')
Expand Down

0 comments on commit 3b60e9a

Please sign in to comment.