Page MenuHomec4science

test_image.py
No OneTemporary

File Metadata

Created
Tue, Apr 30, 20:50

test_image.py

import unittest
from os import sep, path
from os.path import isdir, dirname, basename
import lxml.etree as ET
import sys
import sys
sys.path.append('svgscripts')
from datatypes.faksimile_image import FaksimileImage
from datatypes.image import Image, SVGImage
from datatypes.text_field import TextField
class TestImage(unittest.TestCase):
def test_init(self):
tf = TextField()
image = Image(file_name='test.jpg', height=10, width=10, text_field=tf)
self.assertEqual(image.tag, 'image')
self.assertEqual(image.width, 10)
self.assertEqual(image.text_field.width, 0)
node = ET.Element('svg', attrib={'file': 'test.svg', 'height': '10', 'width': '10'})
image = SVGImage(node=node)
self.assertEqual(image.tag, 'svg-image')
self.assertEqual(image.width, 10)
self.assertEqual(image.file_name, 'test.svg')
def test_attach_object_to_tree(self):
tag = 'faksimile-image'
tf = TextField()
image = Image(file_name='test.jpg', URL='https://www.google.com', height=10, width=10, text_field=tf, 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')
self.assertEqual(len(node.findall(TextField.XML_TAG)), 1)
image = FaksimileImage(file_name='test.jpg', URL='https://www.google.com', height=10, width=10, text_field=tf)
image.attach_object_to_tree(empty_tree)
def test_get_semantic_dict(self):
#tf = TextField()
#image = Image(file_name='test.jpg', height=10, width=10, text_field=tf)
pass
#print(SVGImage.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