def test_rate_query__rate_structure(self):
        """ ... rate_query, different values for rate_structure param."""
        self.initialize_params()
        result = rate_query(self.params)
        self.assertTrue(result)
        self.assertEqual(len(result), 2)
        self.assertEqual(len(result['data']), 2)
        self.assertEqual(result['data']['2.275'], 1)
        self.assertEqual(result['data']['3.705'], 2)

        self.initialize_params({'rate_structure': 'ARM'})
        result = rate_query(self.params)
        self.assertTrue(result)
        self.assertEqual(len(result['data']), 1)
        self.assertEqual(result['data']['0.125'], 1)

        self.initialize_params({'rate_structure': 'ARM', 'loan_term': 15})
        result = rate_query(self.params)
        self.assertTrue(result)
        self.assertEqual(len(result['data']), 1)
        self.assertEqual(result['data']['3.500'], 1)

        # loan_amount is less than min_loan_amt
        self.initialize_params({'rate_structure': 'ARM', 'loan_term': 15, 'loan_amount': 10000})
        result = rate_query(self.params)
        self.assertFalse(result['data'])
        self.assertTrue(result['timestamp'])
    def test_rate_query__rate_structure(self):
        """ ... rate_query, different values for rate_structure param."""
        self.initialize_params()
        result = rate_query(self.params)
        self.assertTrue(result)
        self.assertEqual(len(result), 2)
        self.assertEqual(len(result['data']), 2)
        self.assertEqual(result['data']['2.275'], 1)
        self.assertEqual(result['data']['3.705'], 2)

        self.initialize_params({'rate_structure': 'ARM'})
        result = rate_query(self.params)
        self.assertTrue(result)
        self.assertEqual(len(result['data']), 1)
        self.assertEqual(result['data']['0.125'], 1)

        self.initialize_params({'rate_structure': 'ARM', 'loan_term': 15})
        result = rate_query(self.params)
        self.assertTrue(result)
        self.assertEqual(len(result['data']), 1)
        self.assertEqual(result['data']['3.500'], 1)

        # loan_amount is less than min_loan_amt
        self.initialize_params({'rate_structure': 'ARM', 'loan_term': 15, 'loan_amount': 10000})
        result = rate_query(self.params)
        self.assertFalse(result['data'])
        self.assertFalse(result['timestamp'])
 def test_rate_query__plan_selection_logic(self):
     """ ... see that the correct selection is done when several row of same product_id are present."""
     self.initialize_params({'loan_type': 'FHA'})
     result = rate_query(self.params)
     self.assertTrue(result)
     self.assertEqual(len(result['data']), 1)
     self.assertEqual(result['data']['2.005'], 1)
 def test_rate_query__no_results(self):
     """ ... rate_query with a valid state for which there's no data."""
     self.initialize_params({'state': 'MD'})
     result = rate_query(self.params)
     self.assertFalse(result['data'])
     self.assertTrue(result['timestamp'])
     self.assertEqual(result['timestamp'].date(), datetime.date.today())
    def compare_scenarios_output(self, precalculated_results):
        """ Run scenarios thru API, compare results to <precalculated_results>."""
        passed = True
        failed = []
        for scenario_no in self.test_scenarios:
            # since these scenarios use loan_type=AGENCY
            if scenario_no in ['16', '42']:
                continue
            rcparams = RateCheckerParameters()
            rcparams.set_from_query_params(self.test_scenarios[scenario_no])
            api_result = rate_query(rcparams, data_load_testing=True)
            expected_rate = "%s" % precalculated_results[scenario_no][0]
            expected_points = precalculated_results[scenario_no][1]
            if len(api_result['data']) > 1 or\
                    expected_rate not in api_result['data'] or\
                    expected_points != api_result['data'][expected_rate]:

                if expected_rate is not None and api_result['data']:
                    passed = False
                    failed.append(scenario_no)

        if not passed:
            failed.sort(key=int)
            self.messages.append("The following scenarios don't match: %s " %
                                 failed)
Exemplo n.º 6
0
    def compare_scenarios_output(self, precalculated_results):
        """ Run scenarios thru API, compare results to <precalculated_results>."""
        passed = True
        failed = []
        for scenario_no in self.test_scenarios:
            # since these scenarios use loan_type=AGENCY
            # 29, 32, 41 fail because we don't check min_loan_amount for FHA-HB loans
            if scenario_no in ['16', '42', '29', '32', '41']:
                continue
            rcparams = RateCheckerParameters()
            rcparams.set_from_query_params(self.test_scenarios[scenario_no])
            api_result = rate_query(rcparams, data_load_testing=True)
            expected_rate = "%s" % precalculated_results[scenario_no][0]
            expected_points = precalculated_results[scenario_no][1]
            if len(api_result['data']) > 1 or\
                    expected_rate not in api_result['data'] or\
                    expected_points != api_result['data'][expected_rate]:

                if expected_rate is not None and api_result['data']:
                    passed = False
                    failed.append(scenario_no)

        if not passed:
            failed.sort(key=int)
            raise OaHException("The following scenarios don't match: %s" % failed)
 def test_rate_query__plan_selection_logic(self):
     """ ... see that the correct selection is done when several row of same product_id are present."""
     self.initialize_params({'loan_type': 'FHA'})
     result = rate_query(self.params)
     self.assertTrue(result)
     self.assertEqual(len(result['data']), 1)
     self.assertEqual(result['data']['2.005'], 1)
 def test_rate_query__loan_type(self):
     """ diff values for loan_type param."""
     # actually only HighBalance ones
     self.initialize_params({'loan_type': 'FHA-HB', 'loan_term': 15, 'loan_amount': 10000, 'state': 'VA'})
     result = rate_query(self.params)
     self.assertTrue(result)
     self.assertEqual(len(result['data']), 1)
     self.assertEqual(result['data']['1.705'], 1)
 def test_rate_query__loan_type(self):
     """ diff values for loan_type param."""
     # actually only HighBalance ones
     self.initialize_params({'loan_type': 'FHA-HB', 'loan_term': 15, 'loan_amount': 10000, 'state': 'VA'})
     result = rate_query(self.params)
     self.assertTrue(result)
     self.assertEqual(len(result['data']), 1)
     self.assertEqual(result['data']['1.705'], 1)
 def test_rate_query__no_results(self):
     """ ... rate_query with a valid state for which there's no data."""
     self.initialize_params({'state': 'MD'})
     result = rate_query(self.params)
     self.assertFalse(result['data'])
     self.assertFalse(result['timestamp'])