コード例 #1
0
ファイル: tests.py プロジェクト: rsmitty/goldstone-server
    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)
コード例 #2
0
ファイル: tests.py プロジェクト: leftees/goldstone-server
    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")
コード例 #3
0
ファイル: tests.py プロジェクト: rsmitty/goldstone-server
    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')
コード例 #4
0
ファイル: tests.py プロジェクト: leftees/goldstone-server
    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)
コード例 #5
0
ファイル: tests.py プロジェクト: rsmitty/goldstone-server
    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)
コード例 #6
0
ファイル: tests.py プロジェクト: leftees/goldstone-server
    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)
コード例 #7
0
ファイル: tests.py プロジェクト: bhuvan-rk/goldstone-server
    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)