@@ -68,10 +68,9 @@ def test_input_directories():
68
68
assert len (input_dirs ) > 0
69
69
70
70
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 )
75
74
76
75
77
76
def test_tau_thresholds ():
@@ -301,13 +300,6 @@ def test_get_circulation_from_entries():
301
300
assert circulation == 21
302
301
303
302
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
-
311
303
def test_get_special_addresses ():
312
304
ethereum_special_addresses = hlp .get_special_addresses ('ethereum' )
313
305
assert isinstance (ethereum_special_addresses , list )
@@ -395,63 +387,53 @@ def test_get_output_row(mocker):
395
387
assert csv_row == ['bitcoin' , '2010-01-01' , False , True , 'absolute' , 1 , False , True , 1 , 0 ]
396
388
397
389
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
406
393
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
413
394
get_exclude_contracts_mock .return_value = False
395
+ get_exclude_below_fees_mock = mocker .patch ('tokenomics_decentralization.helper.get_exclude_below_fees_flag' )
414
396
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' )
415
398
get_exclude_below_usd_cent_mock .return_value = False
399
+ get_top_limit_type_mock = mocker .patch ('tokenomics_decentralization.helper.get_top_limit_type' )
416
400
get_top_limit_type_mock .return_value = 'absolute'
401
+ get_top_limit_value_mock = mocker .patch ('tokenomics_decentralization.helper.get_top_limit_value' )
417
402
get_top_limit_value_mock .return_value = 0
418
403
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'
433
406
434
- get_clustering_mock .return_value = False
435
407
get_exclude_contracts_mock .return_value = True
436
408
get_exclude_below_fees_mock .return_value = True
437
409
get_exclude_below_usd_cent_mock .return_value = True
438
- get_top_limit_type_mock .return_value = 'absolute'
439
410
get_top_limit_value_mock .return_value = 10
440
411
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
+
441
423
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 ],
444
426
])
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 :
446
428
lines = f .readlines ()
447
429
assert lines [0 ] == ',' .join (['ledger' , 'snapshot_date' , 'clustering' , 'exclude_contract_addresses' ,
448
430
'top_limit_type' , 'top_limit_value' , 'exclude_below_fees' ,
449
431
'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' ,
451
433
'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' ,
453
435
'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' )
455
437
456
438
457
439
def test_get_active_source_keywords (mocker ):
0 commit comments