Exemple #1
0
 def test_index_pattern_type_geo_point(self):
     """Test type conversion for date type: remains unchanged"""
     self.assertEqual(IndexPattern.get_schema_type('geo_point', False),
                      'geo_point')
     self.assertEqual(IndexPattern.get_schema_type('geo_point', True),
                      'geo_point')
     self.assertEqual(IndexPattern.get_schema_type('geo_point', None),
                      'geo_point')
Exemple #2
0
 def test_index_pattern_type_geo_point(self):
     """Test type conversion for date type: remains unchanged"""
     self.assertEqual(IndexPattern.get_schema_type('geo_point', False),
                      'geo_point')
     self.assertEqual(IndexPattern.get_schema_type('geo_point', True),
                      'geo_point')
     self.assertEqual(IndexPattern.get_schema_type('geo_point', None),
                      'geo_point')
Exemple #3
0
    def test_index_pattern_from_json(self):
        """Test IndexPattern from_json class method"""
        index_pattern = IndexPattern.from_json(self.__index_pattern_json)

        self.assertEqual(index_pattern.time_field_name,
                         'grimoire_creation_date')
        self.assertDictEqual(index_pattern.get_properties(),
                             self.__ref_mapping_props)
Exemple #4
0
    def test_index_pattern_from_json(self):
        """Test IndexPattern from_json class method"""
        index_pattern = IndexPattern.from_json(self.__index_pattern_json)

        self.assertEqual(index_pattern.time_field_name,
                         'grimoire_creation_date')
        self.assertDictEqual(index_pattern.get_properties(),
                             self.__ref_mapping_props)
Exemple #5
0
    def test_schema_compare_distinct(self):
        """Test comparison between Schema properties using its
        compare method"""
        expected_status = 'KO'

        # Check comaprison against the same object slightly modified
        es_mapping = ESMapping.from_json(index_name='git',
                                         mapping_json=self.__mapping_json)

        es_mapping_mod = ESMapping.from_json(index_name='git',
                                             mapping_json=self.__mapping_json)

        #
        # Add fake property to the schema used to COMPARE FROM
        #

        es_mapping_mod.get_properties()['fake_prop'] = 'text'

        # ESMapping vs ESMapping
        result = es_mapping_mod.compare_properties(es_mapping)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['missing'], ['fake_prop'])

        # Check comparison ESMapping vs IndexPattern
        index_pattern = IndexPattern.from_json(self.__index_pattern_json)

        result = es_mapping_mod.compare_properties(index_pattern)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['missing'], ['fake_prop'])

        #
        # Add fake property to the target schemas with different value
        #

        es_mapping.add_property('fake_prop', 'text')
        index_pattern.add_property('fake_prop', 'text')

        # ESMapping vs ESMapping
        result = es_mapping_mod.compare_properties(es_mapping)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['missing'], [])
        self.assertEqual(result['distinct'], ['fake_prop'])

        # Check comparison ESMapping vs IndexPattern
        result = es_mapping_mod.compare_properties(index_pattern)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['missing'], [])
        self.assertEqual(result['distinct'], ['fake_prop'])
Exemple #6
0
    def test_schema_compare_distinct(self):
        """Test comparison between Schema properties using its
        compare method"""
        expected_status = 'KO'

        # Check comaprison against the same object slightly modified
        es_mapping = ESMapping.from_json(index_name='git',
                                         mapping_json=self.__mapping_json)

        es_mapping_mod = ESMapping.from_json(index_name='git',
                                             mapping_json=self.__mapping_json)

        #
        # Add fake property to the schema used to COMPARE FROM
        #

        es_mapping_mod.get_properties()['fake_prop'] = 'text'

        # ESMapping vs ESMapping
        result = es_mapping_mod.compare_properties(es_mapping)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['missing'], ['fake_prop'])

        # Check comparison ESMapping vs IndexPattern
        index_pattern = IndexPattern.from_json(self.__index_pattern_json)

        result = es_mapping_mod.compare_properties(index_pattern)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['missing'], ['fake_prop'])

        #
        # Add fake property to the target schemas with different value
        #

        es_mapping.add_property('fake_prop', 'text')
        index_pattern.add_property('fake_prop', 'text')

        # ESMapping vs ESMapping
        result = es_mapping_mod.compare_properties(es_mapping)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['missing'], [])
        self.assertEqual(result['distinct'], ['fake_prop'])

        # Check comparison ESMapping vs IndexPattern
        result = es_mapping_mod.compare_properties(index_pattern)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['missing'], [])
        self.assertEqual(result['distinct'], ['fake_prop'])
Exemple #7
0
    def test_schema_compare_equal(self):
        """Test comparison between Schema properties using its
        compare method"""

        expected_status = 'OK'

        # Check comparison against the same object
        es_mapping = ESMapping.from_json(index_name='git',
                                         mapping_json=self.__mapping_json)

        # ESMapping vs ESMapping
        result = es_mapping.compare_properties(es_mapping)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['correct'],
                         list(es_mapping.get_properties().keys()))

        # Check comparison ESMapping vs IndexPattern
        index_pattern = IndexPattern.from_json(self.__index_pattern_json)

        result = es_mapping.compare_properties(index_pattern)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['correct'],
                         list(es_mapping.get_properties().keys()))

        # Check comparison IndexPattern vs ESMapping
        result = index_pattern.compare_properties(es_mapping)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['correct'],
                         list(index_pattern.get_properties().keys()))

        #
        # Second schema could have more properties than
        # first one (used to COMPARE FROM it)
        # Add a new property to this second instance
        #

        es_mapping_mod = ESMapping.from_json(index_name='git',
                                             mapping_json=self.__mapping_json)
        es_mapping_mod.get_properties()['fake_prop'] = 0

        # Mapping vs Mapping
        result = es_mapping.compare_properties(es_mapping_mod)
        self.assertEqual(result['status'], expected_status)

        # Index pattern vs Mapping
        result = index_pattern.compare_properties(es_mapping_mod)
        self.assertEqual(result['status'], expected_status)
Exemple #8
0
    def test_schema_compare_equal(self):
        """Test comparison between Schema properties using its
        compare method"""

        expected_status = 'OK'

        # Check comparison against the same object
        es_mapping = ESMapping.from_json(index_name='git',
                                         mapping_json=self.__mapping_json)

        # ESMapping vs ESMapping
        result = es_mapping.compare_properties(es_mapping)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['correct'], list(es_mapping.get_properties().keys()))

        # Check comparison ESMapping vs IndexPattern
        index_pattern = IndexPattern.from_json(self.__index_pattern_json)

        result = es_mapping.compare_properties(index_pattern)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['correct'], list(es_mapping.get_properties().keys()))

        # Check comparison IndexPattern vs ESMapping
        result = index_pattern.compare_properties(es_mapping)
        self.assertEqual(result['status'], expected_status)
        self.assertEqual(result['correct'], list(index_pattern.get_properties().keys()))

        #
        # Second schema could have more properties than
        # first one (used to COMPARE FROM it)
        # Add a new property to this second instance
        #

        es_mapping_mod = ESMapping.from_json(index_name='git',
                                             mapping_json=self.__mapping_json)
        es_mapping_mod.get_properties()['fake_prop'] = 0

        # Mapping vs Mapping
        result = es_mapping.compare_properties(es_mapping_mod)
        self.assertEqual(result['status'], expected_status)

        # Index pattern vs Mapping
        result = index_pattern.compare_properties(es_mapping_mod)
        self.assertEqual(result['status'], expected_status)
Exemple #9
0
 def test_index_pattern_type_number(self):
     """Test type conversion from not analyzed number to number type"""
     self.assertEqual(IndexPattern.get_schema_type('number', False),
                      'number')
Exemple #10
0
 def test_index_pattern_type_keyword(self):
     """Test type conversion from not analyzed string to keyword type"""
     self.assertEqual(IndexPattern.get_schema_type('string', False),
                      'keyword')
Exemple #11
0
 def test_index_pattern_type_text(self):
     """Test type conversion from analyzed string to text type"""
     self.assertEqual(IndexPattern.get_schema_type('string', True),
                      'text')
Exemple #12
0
 def test_index_pattern_type_number(self):
     """Test type conversion from not analyzed number to number type"""
     self.assertEqual(IndexPattern.get_schema_type('number', False),
                      'number')
Exemple #13
0
 def test_index_pattern_type_keyword(self):
     """Test type conversion from not analyzed string to keyword type"""
     self.assertEqual(IndexPattern.get_schema_type('string', False),
                      'keyword')
Exemple #14
0
 def test_index_pattern_type_text(self):
     """Test type conversion from analyzed string to text type"""
     self.assertEqual(IndexPattern.get_schema_type('string', True), 'text')