def setup_module(): # Initialize test image paths/elements/associated crop boxes. global GH_IMAGE_FP, GH_FILE_ELEMENT, GH_CROPPED_IMAGE_FP, \ GH_CROPPED_FILE_ELEMENT, GH_CROPPED_BBOX GH_IMAGE_FP = os.path.join(TEST_DATA_DIR, "grace_hopper.png") GH_FILE_ELEMENT = DataFileElement(GH_IMAGE_FP, readonly=True) assert GH_FILE_ELEMENT.content_type() == 'image/png' GH_CROPPED_IMAGE_FP = \ os.path.join(TEST_DATA_DIR, 'grace_hopper.100x100+100+100.png') GH_CROPPED_FILE_ELEMENT = DataFileElement(GH_CROPPED_IMAGE_FP, readonly=True) assert GH_CROPPED_FILE_ELEMENT.content_type() == 'image/png' GH_CROPPED_BBOX = AxisAlignedBoundingBox([100, 100], [200, 200])
def test_content_type_explicit_type(self) -> None: ex_type = 'image/png' d = DataFileElement('foo.txt', explicit_mimetype=ex_type) self.assertEqual(d.content_type(), ex_type)
def test_content_type(self) -> None: d = DataFileElement('foo.txt') self.assertEqual(d.content_type(), 'text/plain')