def test_field_has_raw_false(self): """field_has_raw returns False if mapping doesn't have a raw field.""" # py26 support with patch.object(DailyIndexDocType, "get_field_mapping") as gfm: field = 'field' gfm.return_value = { 'index': { 'mappings': { 'syslog': { field: { 'mapping': { field: { 'fields': { 'not_raw': True } } } } } } } } result = DailyIndexDocType.field_has_raw('field') self.assertTrue(gfm.called) self.assertFalse(result)
def test_get_field_mapping(self): """get_field_mapping returns the mapping reported by Elasticsearch.""" with patch.object(IndicesClient, "get_field_mapping") as gfm: gfm.return_value = "pass me through" result = DailyIndexDocType.get_field_mapping("field") self.assertEqual(result, "pass me through")
def test_get_field_mapping(self): """get_field_mapping returns the mapping reported by Elasticsearch.""" with patch.object(IndicesClient, "get_field_mapping") as gfm: gfm.return_value = 'pass me through' result = DailyIndexDocType.get_field_mapping('field') self.assertEqual(result, 'pass me through')
def test_field_has_raw_key_error(self): """field_has_raw returns False if KeyError raised.""" # py26 support with patch.object(DailyIndexDocType, "get_field_mapping") as gfm: gfm.side_effect = KeyError result = DailyIndexDocType.field_has_raw("field") self.assertTrue(gfm.called) self.assertFalse(result)
def test_field_has_raw_key_error(self): """field_has_raw returns False if KeyError raised.""" # py26 support with patch.object(DailyIndexDocType, "get_field_mapping") as gfm: gfm.side_effect = KeyError result = DailyIndexDocType.field_has_raw('field') self.assertTrue(gfm.called) self.assertFalse(result)
def test_field_has_raw_false(self): """field_has_raw returns False if mapping doesn't have a raw field.""" # py26 support with patch.object(DailyIndexDocType, "get_field_mapping") as gfm: field = "field" gfm.return_value = { "index": {"mappings": {"syslog": {field: {"mapping": {field: {"fields": {"not_raw": True}}}}}}} } result = DailyIndexDocType.field_has_raw("field") self.assertTrue(gfm.called) self.assertFalse(result)
def test_field_has_raw_false(self): """field_has_raw returns False if mapping doesn't have a raw field.""" # py26 support with patch.object(DailyIndexDocType, "get_field_mapping") as gfm: field = 'field' gfm.return_value = {'index': {'mappings': { 'syslog': {field: {'mapping': {field: {'fields': { 'not_raw': True}}}}}}}} result = DailyIndexDocType.field_has_raw('field') self.assertTrue(gfm.called) self.assertFalse(result)