def test_smart_entity_resolution_cache_hit_entity_match(self, mock_dynamo): entity_match = {"confidence": "0.9", "perm_id": 1234} mock_dynamo.return_value = {"entity_match": entity_match} result = entity_resolution_smart(self.good_event, None) expected_result = {'statusCode': 200, 'body': entity_match} result_json = json.loads(result['body']) self.assertEqual(expected_result['statusCode'], result['statusCode']) self.assertEqual(result_json['resolution_algorithm'], 'entity_match') self.assertEqual(expected_result['body'], result_json)
def test_smart_entity_resolution_cache_hit_manual_override( self, mock_dynamo): manual_override = {"confidence": "1.0", "perm_id": 1234} mock_dynamo.return_value = {"manual_override": manual_override} result = entity_resolution_smart(self.good_event, None) expected_result = {'statusCode': 200, 'body': manual_override} result_json = json.loads(result['body']) self.assertEqual(expected_result['statusCode'], result['statusCode']) self.assertEqual(result_json['resolution_algorithm'], 'manual_override') self.assertEqual(expected_result['body']['resolution_algorithm'], result_json['resolution_algorithm'])
def test_smart_entity_resolution_cache_hit_open_calais(self, mock_dynamo): open_calais = [{ "confidence": "0.9", "is_company_score": "0.9", "perm_id": 1234 }] mock_dynamo.return_value = {"open_calais": open_calais} result = entity_resolution_smart(self.good_event, None) expected_result = {'statusCode': 200, 'body': open_calais[0]} result_json = json.loads(result['body']) self.assertEqual(expected_result['statusCode'], result['statusCode']) self.assertEqual(result_json['resolution_algorithm'], 'open_calais') self.assertEqual(expected_result['body'], result_json)
def test_smart_entity_resolution_cache_hit_open_calais_low_is_company_score( self, mock_dynamo): open_calais = [{"confidence": "0.9", "is_company_score": "0.2"}] mock_dynamo.return_value = {"open_calais": open_calais} result = entity_resolution_smart(self.good_event, None) expected_result = { 'statusCode': 404, 'body': { 'status': 'failed', 'message': 'Could not successfully smart-resolution entity for keyword [test]' } } result_json = json.loads(result['body']) self.assertEqual(expected_result['statusCode'], result['statusCode']) self.assertEqual(expected_result['body'], result_json)
def test_smart_entity_resolution_cache_hit_entity_match_low_confidence( self, mock_dynamo): entity_match = {"confidence": "0.6"} mock_dynamo.return_value = {"entity_match": entity_match} result = entity_resolution_smart(self.good_event, None) expected_result = { 'statusCode': 404, 'body': { 'status': 'failed', 'message': 'Could not successfully smart-resolution entity for keyword [test]' } } result_json = json.loads(result['body']) self.assertEqual(expected_result['statusCode'], result['statusCode']) self.assertEqual(expected_result['body'], result_json)