@@ -395,63 +395,53 @@ def test_get_output_row(mocker):
395395 assert csv_row == ['bitcoin' , '2010-01-01' , False , True , 'absolute' , 1 , False , True , 1 , 0 ]
396396
397397
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-
398+ def test_get_output_filename (mocker ):
402399 get_output_directories_mock = mocker .patch ('tokenomics_decentralization.helper.get_output_directories' )
403400 get_output_directories_mock .return_value = [pathlib .Path (__file__ ).resolve ().parent ]
404-
405- get_clustering_mock = mocker .patch ('tokenomics_decentralization.helper.get_clustering_flag' )
406401 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
413402 get_exclude_contracts_mock .return_value = False
403+ get_exclude_below_fees_mock = mocker .patch ('tokenomics_decentralization.helper.get_exclude_below_fees_flag' )
414404 get_exclude_below_fees_mock .return_value = False
405+ get_exclude_below_usd_cent_mock = mocker .patch ('tokenomics_decentralization.helper.get_exclude_below_usd_cent_flag' )
415406 get_exclude_below_usd_cent_mock .return_value = False
407+ get_top_limit_type_mock = mocker .patch ('tokenomics_decentralization.helper.get_top_limit_type' )
416408 get_top_limit_type_mock .return_value = 'absolute'
409+ get_top_limit_value_mock = mocker .patch ('tokenomics_decentralization.helper.get_top_limit_value' )
417410 get_top_limit_value_mock .return_value = 0
418411
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' )
412+ output_filename = hlp .get_output_filename ()
413+ assert output_filename == pathlib .Path (__file__ ).resolve ().parent / 'output.csv'
433414
434- get_clustering_mock .return_value = False
435415 get_exclude_contracts_mock .return_value = True
436416 get_exclude_below_fees_mock .return_value = True
437417 get_exclude_below_usd_cent_mock .return_value = True
438- get_top_limit_type_mock .return_value = 'absolute'
439418 get_top_limit_value_mock .return_value = 10
440419
420+ output_filename = hlp .get_output_filename ()
421+ assert output_filename == pathlib .Path (__file__ ).resolve ().parent / 'output-exclude_contract_addresses-absolute_10-exclude_below_fees-exclude_below_usd_cent.csv'
422+
423+
424+ def test_write_csv_output (mocker ):
425+ get_metrics_mock = mocker .patch ('tokenomics_decentralization.helper.get_metrics' )
426+ get_metrics_mock .return_value = ['hhi' ]
427+
428+ get_output_filename_mock = mocker .patch ('tokenomics_decentralization.helper.get_output_filename' )
429+ get_output_filename_mock .return_value = pathlib .Path (__file__ ).resolve ().parent / 'output.csv'
430+
441431 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 ],
432+ ['bitcoin' , '2010-01-01' , True , False , 'absolute' , 0 , False , False , 100 ],
433+ ['ethereum' , '2010-01-01' , True , False , 'absolute' , 0 , False , False , 200 ],
444434 ])
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 :
435+ with open (pathlib .Path (__file__ ).resolve ().parent / 'output.csv' ) as f :
446436 lines = f .readlines ()
447437 assert lines [0 ] == ',' .join (['ledger' , 'snapshot_date' , 'clustering' , 'exclude_contract_addresses' ,
448438 'top_limit_type' , 'top_limit_value' , 'exclude_below_fees' ,
449439 'exclude_below_usd_cent' , 'hhi' ]) + '\n '
450- assert lines [1 ] == ',' .join (['bitcoin' , '2010-01-01' , 'False ' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
440+ assert lines [1 ] == ',' .join (['bitcoin' , '2010-01-01' , 'True ' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
451441 '100' ]) + '\n '
452- assert lines [2 ] == ',' .join (['ethereum' , '2010-01-01' , 'False ' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
442+ assert lines [2 ] == ',' .join (['ethereum' , '2010-01-01' , 'True ' , 'False' , 'absolute' , '0' , 'False' , 'False' ,
453443 '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' )
444+ os .remove (pathlib .Path (__file__ ).resolve ().parent / 'output.csv' )
455445
456446
457447def test_get_active_source_keywords (mocker ):
0 commit comments