def test_run_matcher(self): (start, expected) = self._get_log_data("run_matcher") for input,result in zip(start,expected): product_names = [product._name for product in input[4][0]] customer_names = [customer._name for customer in input[4][1]] suitability = product_matcher.suitability_matrix(customer_names, product_names) self.assertEqual(result[0],product_matcher.run_matcher(suitability))
def test_match_products(self): cases = ( [1, 0], [1], [0], [0,2,1,3], [2,0,3], [2,0,3], [-1,0,-1] ) for i, expected in enumerate(cases): suitability = product_matcher.suitability_matrix(*self._get_matcher(i)) self.assertEqual(expected, product_matcher.match_products(suitability))
def test_suitability_matrix(self): cases = ( [[4.5,7],[4.5,4]], [[4.5,7]], [[4.5]], [[4.5,3,3,3],[1.5,3,4.5,3],[4.5,4,4,4],[1.5,3,3,4.5]], [[3,3,4.5,4.5],[11.25,4,6,4],[3,3,4.5,4.5]], [[11,11,11,11.25],[2,2,2,4.5],[3,3,3,6.75]], [[2.25],[4.5],[3]] ) for i, expected in enumerate(cases): (customer_names, product_names) = self._get_matcher(i) self.assertEqual(expected,product_matcher.suitability_matrix(customer_names, product_names))