def test_pipeline_sales(self):
		'''
		When dimensions get merged, the Unknown physical dimension classification (300055642)
		gets dropped if there are any other classifications.
		'''
		h1 = vocab.Height(ident='', content=9.0)
		h1.unit = vocab.instances.get('inches')
		self.assertEqual({c._label for c in h1.classified_as}, {'Height'})

		h2 = vocab.PhysicalDimension(ident='', content=9.0)
		self.assertEqual({c._label for c in h2.classified_as}, {'Unknown physical dimension'})
		
		merger = CromObjectMerger()
		
		h = merger.merge(h1, h2)
		self.assertEqual({c._label for c in h.classified_as}, {'Height'})
Exemple #2
0
def extract_physical_dimensions(dimstr, **kwargs):
    dimensions = dimensions_cleaner(dimstr, **kwargs)
    if dimensions:
        for orig_d in dimensions:
            dimdata = normalized_dimension_object(orig_d, source=dimstr)
            if dimdata:
                dimension, label = dimdata
                if dimension.which == 'height':
                    dim = vocab.Height(ident='')
                elif dimension.which == 'width':
                    dim = vocab.Width(ident='')
                else:
                    dim = vocab.PhysicalDimension(ident='')
                dim.value = dimension.value
                dim.identified_by = model.Name(ident='', content=label)
                unit = vocab.instances.get(dimension.unit)
                if unit:
                    dim.unit = unit
                yield dim