@@ -17,25 +17,30 @@ def setUp(self):
1717
1818 def test_client (self ):
1919 """
20- Tests for client configuration into presalytics api
20+ Tests for client configuration into presalytics api via device grant
2121 """
22- client = presalytics .client .api .Client (config_file = self .config_file )
23- username = os .environ ["PRESALYTICS_USERNAME" ]
24- self .assertEqual (client .username , username )
25- self .assertEqual (client .ooxml_automation .api_client .configuration .host , os .environ ["OOXML_AUTOMATION_HOST" ])
26- self .assertNotEqual (client .token_util .token .get ("access_token" , None ), None )
22+ if not presalytics .CONFIG .get ("PASSWORD" , None ):
23+ client = presalytics .client .api .Client (config_file = self .config_file )
24+ username = os .environ ["PRESALYTICS_USERNAME" ]
25+ self .assertEqual (client .username , username )
26+ self .assertEqual (client .ooxml_automation .api_client .configuration .host , os .environ ["OOXML_AUTOMATION_HOST" ])
27+ self .assertNotEqual (client .token_util .token .get ("access_token" , None ), None )
2728
2829 def test_password_grant (self ):
29- username = presalytics .CONFIG .get ("USERNAME" )
30- password = presalytics .CONFIG .get ("PASSWORD" )
31- client_id = os .environ .get ("CLIENT_ID" )
32- client_secret = os .environ .get ("CLIENT_SECRET" )
33- client = presalytics .client .api .Client (
34- username = username ,
35- password = password ,
36- client_id = client_id ,
37- client_secret = client_secret
38- )
30+ """
31+ tests if password grant works
32+ """
33+ if presalytics .CONFIG .get ("PASSWORD" , None ):
34+ username = presalytics .CONFIG .get ("USERNAME" )
35+ password = presalytics .CONFIG .get ("PASSWORD" )
36+ client_id = os .environ .get ("CLIENT_ID" )
37+ client_secret = os .environ .get ("CLIENT_SECRET" )
38+ client = presalytics .client .api .Client (
39+ username = username ,
40+ password = password ,
41+ client_id = client_id ,
42+ client_secret = client_secret
43+ )
3944
4045 def test_module_config (self ):
4146 from test .files .config import PRESALYTICS
@@ -54,9 +59,8 @@ def test_api_exception(self):
5459 self .assertEqual (status , 404 )
5560
5661 def test_file_download (self ):
57- from test .files .config import PRESALYTICS
5862 test_upload_file = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'files' , 'star.pptx' )
59- client = presalytics .client .api .Client ( config = PRESALYTICS )
63+ client = presalytics .client .api .get_client ( )
6064 try :
6165 test_story = client .story .story_post_file (file = test_upload_file )
6266 download_folder = os .path .dirname (os .path .abspath (__file__ ))
0 commit comments