@@ -1298,9 +1298,11 @@ def run_stream(self):
12981298 asyncio .gather (self .stream_reader (), return_exceptions = False )
12991299 )
13001300
1301- async def getDataLoop (self ):
1301+ async def getDataLoop (self , no_url_cache_loop = False ):
13021302 # We iterate multiple times to see if the url caching works.
13031303 await self .getData ()
1304+ if no_url_cache_loop :
1305+ return
13041306
13051307 print ("First getData cycle completed, waiting 10 secs for second cycle." )
13061308 await asyncio .sleep (10 )
@@ -1310,13 +1312,22 @@ async def getDataLoop(self):
13101312 await asyncio .sleep (10 )
13111313 await self .getData ()
13121314
1313- def run_in_console (self , test_data_folder = None , data_parser = "EnvoyMeteredWithCT" ):
1315+ def run_in_console (
1316+ self ,
1317+ test_data_folder = None ,
1318+ data_parser = "EnvoyMeteredWithCT" ,
1319+ no_url_cache_loop = False ,
1320+ token_type = "owner" ,
1321+ ):
13141322 """If running this module directly, print all the values in the console."""
13151323 import pprint
13161324
13171325 print ("Reading..." )
13181326
13191327 if test_data_folder :
1328+ if token_type :
1329+ self .token_type = token_type
1330+
13201331 _parser_mapping = {
13211332 "EnvoyStandard" : EnvoyStandard ,
13221333 "EnvoyMetered" : EnvoyMetered ,
@@ -1329,7 +1340,10 @@ def run_in_console(self, test_data_folder=None, data_parser="EnvoyMeteredWithCT"
13291340 else :
13301341 loop = asyncio .get_event_loop ()
13311342 loop .run_until_complete (
1332- asyncio .gather (self .getDataLoop (), return_exceptions = False )
1343+ asyncio .gather (
1344+ self .getDataLoop (no_url_cache_loop ),
1345+ return_exceptions = False ,
1346+ )
13331347 )
13341348
13351349 loop = asyncio .get_event_loop ()
@@ -1423,6 +1437,13 @@ def run_in_console(self, test_data_folder=None, data_parser="EnvoyMeteredWithCT"
14231437 choices = ["EnvoyStandard" , "EnvoyMetered" , "EnvoyMeteredWithCT" ],
14241438 default = "EnvoyMeteredWithCT" ,
14251439 )
1440+ parser .add_argument (
1441+ "--token-type" ,
1442+ dest = "token_type" ,
1443+ help = "When using test data, then use this token type for parsing the endpoints" ,
1444+ choices = ["owner" , "installer" ],
1445+ default = "installer" ,
1446+ )
14261447
14271448 parser .add_argument (
14281449 "--disable-negative-production" ,
@@ -1436,6 +1457,12 @@ def run_in_console(self, test_data_folder=None, data_parser="EnvoyMeteredWithCT"
14361457 help = "Disable installer account use" ,
14371458 action = "store_true" ,
14381459 )
1460+ parser .add_argument (
1461+ "--no-url-cache-loop" ,
1462+ dest = "no_url_cache_loop" ,
1463+ help = "Do not run multiple url fetch loops, just once is fine." ,
1464+ action = "store_true" ,
1465+ )
14391466 args = parser .parse_args ()
14401467
14411468 logging .basicConfig (level = logging .INFO )
@@ -1459,4 +1486,6 @@ def run_in_console(self, test_data_folder=None, data_parser="EnvoyMeteredWithCT"
14591486 TESTREADER .run_in_console (
14601487 test_data_folder = args .test_data ,
14611488 data_parser = args .data_parser ,
1489+ no_url_cache_loop = args .no_url_cache_loop ,
1490+ token_type = args .token_type ,
14621491 )
0 commit comments