<s> import sys <EOL> import os , sys <EOL> from lxml import etree <EOL> from CIP . logic . geometry_topology_data import * <EOL> this_dir = os . path . dirname ( os . path . realpath ( __file__ ) ) <EOL> xml_file = os . path . join ( this_dir , "<STR_LIT>" ) <EOL> xsd_file = os . path . abspath ( os . path . join ( this_dir , "<STR_LIT:..>" , "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> def test_geometry_topology_data_schema ( ) : <EOL> """<STR_LIT>""" <EOL> with open ( xml_file , '<STR_LIT>' ) as f : <EOL> xml = f . read ( ) <EOL> with open ( xsd_file , '<STR_LIT>' ) as f : <EOL> xsd = f . read ( ) <EOL> schema = etree . XMLSchema ( etree . XML ( xsd ) ) <EOL> xmlparser = etree . XMLParser ( schema = schema ) <EOL> etree . fromstring ( xml , xmlparser ) <EOL> def test_geometry_topology_data_write_read ( ) : <EOL> """<STR_LIT>""" <EOL> g = GeometryTopologyData ( ) <EOL> g . num_dimensions = <NUM_LIT:3> <EOL> g . coordinate_system = g . RAS <EOL> g . lps_to_ijk_transformation_matrix = [ [ - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> ] , [ <NUM_LIT:0> , - <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ] ] <EOL> g . add_point ( Point ( <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:1> , [ <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT:3> ] , description = "<STR_LIT>" , format_ = "<STR_LIT>" ) ) <EOL> g . add_point ( Point ( <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:1> , coordinate = [ <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT:3> ] , format_ = "<STR_LIT>" ) ) <EOL> g . add_bounding_box ( BoundingBox ( <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:1> , start = [ <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT:3> ] , size = [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] , format_ = "<STR_LIT>" ) ) <EOL> g . add_bounding_box ( BoundingBox ( <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:1> , start = [ <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT:3> ] , size = [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] , format_ = "<STR_LIT>" ) ) <EOL> xml = g . to_xml ( ) <EOL> with open ( xml_file , '<STR_LIT>' ) as f : <EOL> expectedOutput = f . read ( ) <EOL> assert xml == expectedOutput , "<STR_LIT>" + xml <EOL> with open ( xsd_file , '<STR_LIT>' ) as f : <EOL> xsd = f . read ( ) <EOL> schema = etree . XMLSchema ( etree . XML ( xsd ) ) <EOL> xmlparser = etree . XMLParser ( schema = schema ) <EOL> etree . fromstring ( xml , xmlparser ) </s>
