66import presalytics
77import io
88import lxml
9+ from test import get_test_client
910if typing .TYPE_CHECKING :
1011 from presalytics .client .presalytics_story import Story , OoxmlDocument
1112 from presalytics .client .presalytics_ooxml_automation .models import ChartChartDataDTO , TableTableDataDTO
@@ -15,10 +16,8 @@ class TestComponents(unittest.TestCase):
1516 """
1617 Test module features thatr render stories to dashboards or other formats
1718 """
18- def setUp (self ):
19- pass
2019
21- def test_render_matplotlib_plot (self ):
20+ def test_render_matploytlib_plot (self ):
2221 presalytics .autodiscover_paths .append ('test/files' )
2322 presalytics .COMPONENTS = presalytics .story .components .ComponentRegistry (autodiscover_paths = presalytics .autodiscover_paths )
2423 test_file = os .path .join (os .path .dirname (__file__ ), 'files' , 'matplotlib-outline.yaml' )
@@ -33,8 +32,7 @@ def test_xml_widget(self):
3332 story = presalytics .create_story_from_ooxml_file (tmp_filename )
3433 outline = presalytics .StoryOutline .load (story .outline )
3534 old_widget = outline .pages [0 ].widgets [0 ]
36- client = presalytics .Client ()
37- childs = client .ooxml_automation .documents_childobjects_get_id (old_widget .data ["document_ooxml_id" ])
35+ childs = get_test_client ().ooxml_automation .documents_childobjects_get_id (old_widget .data ["document_ooxml_id" ])
3836 endpoint_map = presalytics .OoxmlEndpointMap .shape ()
3937 object_type = endpoint_map .get_object_type ()
4038 info = next (x for x in childs if x .object_type == object_type )
@@ -67,7 +65,7 @@ def test_xml_widget(self):
6765
6866 presalytics .COMPONENTS .register (widget )
6967 story .outline = outline .dump ()
70- client .story .story_id_put (story .id , story )
68+ get_test_client () .story .story_id_put (story .id , story )
7169 html = presalytics .Revealer (outline ).package_as_standalone ().decode ('utf-8' )
7270 self .assertIsInstance (html , str )
7371 os .remove (tmp_filename )
@@ -89,8 +87,7 @@ def test_bytesio_upload(self):
8987 with open (test_file , 'rb' ) as f :
9088 _bytes = io .BytesIO (f .read ())
9189
92- client = presalytics .Client ()
93- story = presalytics .story_post_file_bytes (client , _bytes , "testfile.pptx" )
90+ story = presalytics .story_post_file_bytes (get_test_client (), _bytes , "testfile.pptx" )
9491 from presalytics .client .presalytics_story .models .story import Story
9592 self .assertIsInstance (story , Story )
9693
@@ -123,11 +120,10 @@ def test_chart_update(self):
123120 document : "OoxmlDocument"
124121
125122 test_file = os .path .join (os .path .dirname (__file__ ), "files" , "bubblechart.pptx" )
126- client = presalytics .Client ()
127- story = client .story .story_post_file (file = [test_file ])
128- story_detailed = client .story .story_id_get (story .id , include_relationships = True )
123+ story = get_test_client ().story .story_post_file (file = [test_file ])
124+ story_detailed = get_test_client ().story .story_id_get (story .id , include_relationships = True )
129125 document = story_detailed .ooxml_documents [0 ]
130- object_tree = client .ooxml_automation .documents_childobjects_get_id (document .ooxml_automation_id )
126+ object_tree = get_test_client () .ooxml_automation .documents_childobjects_get_id (document .ooxml_automation_id )
131127 endpoint_map = presalytics .OoxmlEndpointMap .chart ()
132128 object_type = endpoint_map .get_object_type ()
133129 chart_id = next (entity .entity_id for entity in object_tree if entity .object_type == object_type )
@@ -170,11 +166,10 @@ def test_table_update(self):
170166 dto : "TableTableDataDTO"
171167
172168 test_file = os .path .join (os .path .dirname (__file__ ), "files" , "table.pptx" )
173- client = presalytics .Client ()
174- story = client .story .story_post_file (file = [test_file ])
175- story_detailed = client .story .story_id_get (story .id , include_relationships = True )
169+ story = get_test_client ().story .story_post_file (file = [test_file ])
170+ story_detailed = get_test_client ().story .story_id_get (story .id , include_relationships = True )
176171 document = story_detailed .ooxml_documents [0 ]
177- object_tree = client .ooxml_automation .documents_childobjects_get_id (document .ooxml_automation_id )
172+ object_tree = get_test_client () .ooxml_automation .documents_childobjects_get_id (document .ooxml_automation_id )
178173 endpoint_map = presalytics .OoxmlEndpointMap .table ()
179174 object_type = endpoint_map .get_object_type ()
180175 table_id = next (entity .entity_id for entity in object_tree if entity .object_type == object_type )
0 commit comments