37 lines
3.7 KiB
Python
37 lines
3.7 KiB
Python
|
|
import unittest
|
||
|
|
from block import __main__
|
||
|
|
|
||
|
|
class TestBlock(unittest.TestCase):
|
||
|
|
|
||
|
|
def test_main_success(self):
|
||
|
|
# result = __main__(record_counts_negative_trade_count=7, record_counts_installment_trade_count=8,
|
||
|
|
# record_counts_total_trade_count=18, record_counts_total_inquiry_count=3,
|
||
|
|
# record_counts_revolving_trade_count=9, score_results=600.0,
|
||
|
|
# installment_amount_monthly_payment=572, revolving_amount_percent_available_credit=18,
|
||
|
|
# G069S=3, AT24S=6, BR02S=1, BI02S=5, AGG103=27642.0, ALL231=-2.0, AT12S=7, IN20S=166,
|
||
|
|
# AT33A=38353, AT35A=5479, AT28A=54087, AT34B=71, S061S=1, RE102S=2000)
|
||
|
|
|
||
|
|
# expected_result = {'score_results': 600.0, 'AT34B': 71, 'AT12S': 7, 'revolving_amount_percent_available_credit': 18, 'AT28A': 54087, 'record_counts_total_trade_count': 18, 'record_counts_negative_trade_count': 7, 'record_counts_revolving_trade_count': 9, 'AT33A': 38353, 'AT35A': 5479, 'record_counts_total_inquiry_count': 3, 'IN20S': 150, 'RE102S': 2000, 'installment_amount_monthly_payment': 572, 'S061S': 1, 'record_counts_installment_trade_count': 8, 'BR02S': 1, 'AGG103': 27642.0, 'ALL231': 0.0, 'G069S': 3, 'AT24S': 6, 'BI02S': 3}
|
||
|
|
|
||
|
|
result = __main__(record_counts_revolving_trade_count = 9.0,record_counts_total_trade_count = 18.0,score_results = 600.0,total_amount_current_balance = 46764.0,total_amount_high_credit = 53807.0,revolving_amount_credit_limit = 2000.0,revolving_amount_percent_available_credit = 18.0,revolving_amount_current_balance = 1635.0,revolving_amount_monthly_payment = 56.0,revolving_amount_high_credit = 1720.0,closed_with_balance_amount_current_balance = 8411.0,closed_with_balance_amount_monthly_payment = 0.0,AGG101 = 11043.0,AGG102 = 24994.0,AT09S = 4.0,AT20S = 166.0,AT31S = 71.0,BALMAG01 = 196.0,BC21S = 4.0,PAYMNT10 = 4.0,REV83 = 0.0,US01S = 0.0,monthly_income = 2200.00,total_amount_monthly_payment = 628.0,internal_monthly_payment = None)
|
||
|
|
|
||
|
|
expected_result = {'pti': 0.32284999999999997, 'score_results': 600.0, 'revolving_amount_monthly_payment': 56.0, 'AT31S': 71.0, 'total_amount_high_credit': 53807.0, 'AT20S': 166.0, 'BALMAG01': 196.0, 'record_counts_revolving_trade_count': 9.0, 'PAYMNT10': 4.0, 'closed_with_balance_amount_current_balance': 8411.0, 'REV83': 0.0, 'AGG102': 24994.0, 'BC21S': 4.0, 'record_counts_total_trade_count': 18.0, 'revolving_amount_current_balance': 1635.0, 'total_amount_current_balance': 46764.0, 'revolving_amount_high_credit': 1720.0, 'US01S': 0, 'AGG101': 11043.0, 'closed_with_balance_amount_monthly_payment': 0.0, 'revolving_amount_credit_limit': 2000.0, 'revolving_amount_percent_available_credit': 18.0, 'AT09S': 4.0}
|
||
|
|
|
||
|
|
for key, expected_value in expected_result.items():
|
||
|
|
if isinstance(expected_value, float):
|
||
|
|
self.assertAlmostEqual(result[key], expected_value, places=6, msg=f"Mismatch for {key}")
|
||
|
|
else:
|
||
|
|
self.assertEqual(result[key], expected_value, msg=f"Mismatch for {key}")
|
||
|
|
|
||
|
|
# def test_main_invalid_input(self):
|
||
|
|
# with self.assertRaises(TypeError):
|
||
|
|
# __main__(record_counts_negative_trade_count=7, record_counts_installment_trade_count=8,
|
||
|
|
# record_counts_total_trade_count=18, record_counts_total_inquiry_count=3,
|
||
|
|
# record_counts_revolving_trade_count=9, score_results=600, installment_amount_monthly_payment=572,
|
||
|
|
# revolving_amount_percent_available_credit=18, G069S=3, AT24S=6, BR02S=1, BI02S=5,
|
||
|
|
# AGG103=27642, ALL231=-2, AT12S=7, IN20S=166, AT33A=38353, AT35A=5479, AT28A=54087,
|
||
|
|
# AT34B=71, S061S=1, RE102S=2000)
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
unittest.main()
|