33 lines
2.3 KiB
Python
33 lines
2.3 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}
|
||
|
|
|
||
|
|
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()
|