@@ -68,10 +68,9 @@ def test_input_directories():
6868 assert len (input_dirs ) > 0
6969
7070
71- def test_output_directories ():
72- output_dirs = hlp .get_output_directories ()
73- assert isinstance (output_dirs , list )
74- assert len (output_dirs ) > 0
71+ def test_output_directory ():
72+ output_dir = hlp .get_output_directory ()
73+ assert isinstance (output_dir , pathlib .Path )
7574
7675
7776def test_tau_thresholds ():
@@ -301,13 +300,6 @@ def test_get_circulation_from_entries():
301300 assert circulation == 21
302301
303302
304- def test_get_output_files (mocker ):
305- get_config_mock = mocker .patch ("tokenomics_decentralization.helper.get_output_directories" )
306- get_config_mock .return_value = [pathlib .Path (__file__ ).resolve ().parent ]
307- output_files = hlp .get_output_files ()
308- assert isinstance (output_files , list )
309-
310-
311303def test_get_special_addresses ():
312304 ethereum_special_addresses = hlp .get_special_addresses ('ethereum' )
313305 assert isinstance (ethereum_special_addresses , list )
@@ -395,63 +387,53 @@ def test_get_output_row(mocker):
395387 assert csv_row == ['bitcoin' , '2010-01-01' , False , True , 'absolute' , 1 , False , True , 1 , 0 ]
396388
397389
398- def test_write_csv_output (mocker ):
399- get_metrics_mock = mocker .patch ('tokenomics_decentralization.helper.get_metrics' )
400- get_metrics_mock .return_value = ['hhi' ]
401-
402- get_output_directories_mock = mocker .patch ('tokenomics_decentralization.helper.get_output_directories' )
403- get_output_directories_mock .return_value = [pathlib .Path (__file__ ).resolve ().parent ]
404-
405- get_clustering_mock = mocker .patch ('tokenomics_decentralization.helper.get_clustering_flag' )
390+ def test_get_output_filename (mocker ):
391+ get_output_directory_mock = mocker .patch ('tokenomics_decentralization.helper.get_output_directory' )
392+ get_output_directory_mock .return_value = pathlib .Path (__file__ ).resolve ().parent
406393 get_exclude_contracts_mock = mocker .patch ('tokenomics_decentralization.helper.get_exclude_contracts_flag' )
407- get_exclude_below_fees_mock = mocker .patch ('tokenomics_decentralization.helper.get_exclude_below_fees_flag' )
408- get_exclude_below_usd_cent_mock = mocker .patch ('tokenomics_decentralization.helper.get_exclude_below_usd_cent_flag' )
409- get_top_limit_type_mock = mocker .patch ('tokenomics_decentralization.helper.get_top_limit_type' )
410- get_top_limit_value_mock = mocker .patch ('tokenomics_decentralization.helper.get_top_limit_value' )
411-
412- get_clustering_mock .return_value = True
413394 get_exclude_contracts_mock .return_value = False
395+ get_exclude_below_fees_mock = mocker .patch ('tokenomics_decentralization.helper.get_exclude_below_fees_flag' )
414396 get_exclude_below_fees_mock .return_value = False
397+ get_exclude_below_usd_cent_mock = mocker .patch ('tokenomics_decentralization.helper.get_exclude_below_usd_cent_flag' )
415398 get_exclude_below_usd_cent_mock .return_value = False
399+ get_top_limit_type_mock = mocker .patch ('tokenomics_decentralization.helper.get_top_limit_type' )
416400 get_top_limit_type_mock .return_value = 'absolute'
401+ get_top_limit_value_mock = mocker .patch ('tokenomics_decentralization.helper.get_top_limit_value' )
417402 get_top_limit_value_mock .return_value = 0
418403
419- hlp .write_csv_output ([
420- ['bitcoin' , '2010-01-01' , True , False , 'absolute' , 0 , False , False , 100 ],
421- ['ethereum' , '2010-01-01' , True , False , 'absolute' , 0 , False , False , 200 ],
422- ])
423- with open (pathlib .Path (__file__ ).resolve ().parent / 'output.csv' ) as f :
424- lines = f .readlines ()
425- assert lines [0 ] == ',' .join (['ledger' , 'snapshot_date' , 'clustering' , 'exclude_contract_addresses' ,
426- 'top_limit_type' , 'top_limit_value' , 'exclude_below_fees' ,
427- 'exclude_below_usd_cent' , 'hhi' ]) + '\n '
428- assert lines [1 ] == ',' .join (['bitcoin' , '2010-01-01' , 'True' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
429- '100' ]) + '\n '
430- assert lines [2 ] == ',' .join (['ethereum' , '2010-01-01' , 'True' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
431- '200' ]) + '\n '
432- os .remove (pathlib .Path (__file__ ).resolve ().parent / 'output.csv' )
404+ output_filename = hlp .get_output_filename ()
405+ assert output_filename == pathlib .Path (__file__ ).resolve ().parent / 'output.csv'
433406
434- get_clustering_mock .return_value = False
435407 get_exclude_contracts_mock .return_value = True
436408 get_exclude_below_fees_mock .return_value = True
437409 get_exclude_below_usd_cent_mock .return_value = True
438- get_top_limit_type_mock .return_value = 'absolute'
439410 get_top_limit_value_mock .return_value = 10
440411
412+ output_filename = hlp .get_output_filename ()
413+ assert output_filename == pathlib .Path (__file__ ).resolve ().parent / 'output-exclude_contract_addresses-absolute_10-exclude_below_fees-exclude_below_usd_cent.csv'
414+
415+
416+ def test_write_csv_output (mocker ):
417+ get_metrics_mock = mocker .patch ('tokenomics_decentralization.helper.get_metrics' )
418+ get_metrics_mock .return_value = ['hhi' ]
419+
420+ get_output_filename_mock = mocker .patch ('tokenomics_decentralization.helper.get_output_filename' )
421+ get_output_filename_mock .return_value = pathlib .Path (__file__ ).resolve ().parent / 'output.csv'
422+
441423 hlp .write_csv_output ([
442- ['bitcoin' , '2010-01-01' , False , False , 'absolute' , 0 , False , False , 100 ],
443- ['ethereum' , '2010-01-01' , False , False , 'absolute' , 0 , False , False , 200 ],
424+ ['bitcoin' , '2010-01-01' , True , False , 'absolute' , 0 , False , False , 100 ],
425+ ['ethereum' , '2010-01-01' , True , False , 'absolute' , 0 , False , False , 200 ],
444426 ])
445- with open (pathlib .Path (__file__ ).resolve ().parent / 'output-no_clustering-exclude_contract_addresses-absolute_10-exclude_below_fees-exclude_below_usd_cent .csv' ) as f :
427+ with open (pathlib .Path (__file__ ).resolve ().parent / 'output.csv' ) as f :
446428 lines = f .readlines ()
447429 assert lines [0 ] == ',' .join (['ledger' , 'snapshot_date' , 'clustering' , 'exclude_contract_addresses' ,
448430 'top_limit_type' , 'top_limit_value' , 'exclude_below_fees' ,
449431 'exclude_below_usd_cent' , 'hhi' ]) + '\n '
450- assert lines [1 ] == ',' .join (['bitcoin' , '2010-01-01' , 'False ' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
432+ assert lines [1 ] == ',' .join (['bitcoin' , '2010-01-01' , 'True ' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
451433 '100' ]) + '\n '
452- assert lines [2 ] == ',' .join (['ethereum' , '2010-01-01' , 'False ' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
434+ assert lines [2 ] == ',' .join (['ethereum' , '2010-01-01' , 'True ' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
453435 '200' ]) + '\n '
454- os .remove (pathlib .Path (__file__ ).resolve ().parent / 'output-no_clustering-exclude_contract_addresses-absolute_10-exclude_below_fees-exclude_below_usd_cent .csv' )
436+ os .remove (pathlib .Path (__file__ ).resolve ().parent / 'output.csv' )
455437
456438
457439def test_get_active_source_keywords (mocker ):
0 commit comments