Beispiel #1
0
    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)
Beispiel #2
0
    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")
Beispiel #3
0
    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')
Beispiel #4
0
    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)
Beispiel #5
0
    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)
Beispiel #6
0
    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)
Beispiel #7
0
    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)