Page MenuHomec4science

test_image.py
No OneTemporary

File Metadata

Created
Sun, May 12, 14:04

test_image.py

import unittest
from os import sep, path
from os.path import isdir, dirname, basename
import lxml.etree as ET
import sys
from datatypes.image import Image
class TestImage(unittest.TestCase):
def test_init(self):
image = Image(file_name='test.jpg', height=10, width=10)
self.assertEqual(image.tag, 'image')
self.assertEqual(image.width, 10)
def test_attach_object_to_tree(self):
tag = 'faksimile-image'
image = Image(file_name='test.jpg', height=10, width=10, tag=tag)
empty_tree = ET.ElementTree(ET.Element('faksimile'))
image.attach_object_to_tree(empty_tree)
self.assertEqual(image.tag, tag)
for node in empty_tree.getroot().xpath('//' + image.tag):
self.assertEqual(node.get('file-name'), 'test.jpg')
self.assertEqual(node.get('height'), '10')
self.assertEqual(node.get('width'), '10')
def test_get_semantic_dict(self):
image = Image(file_name='test.jpg', height=10, width=10)
#print(Image.get_semantic_dictionary())
#self.assertEqual(image.get_data_dictionary()['body'].get('height'), 10)
#self.assertEqual(image.get_data_dictionary()['body'].get('width'), 10)
if __name__ == "__main__":
unittest.main()

Event Timeline