1
1
import os
2
2
import time
3
- from itertools import chain
4
3
5
4
from nose .plugins .skip import SkipTest
6
5
@@ -46,6 +45,7 @@ def get_xml(self):
46
45
47
46
48
47
class HyperlinkVanillaTestCase (_TranslationTestCase ):
48
+
49
49
relationship_dict = {
50
50
'rId0' : 'www.google.com' ,
51
51
}
@@ -296,12 +296,40 @@ class TableTag(_TranslationTestCase):
296
296
'''
297
297
298
298
def get_xml (self ):
299
- table = DXB .table (num_rows = 2 , num_columns = 2 , text = chain (
300
- [DXB .p_tag ('AAA' )],
301
- [DXB .p_tag ('BBB' )],
302
- [DXB .p_tag ('CCC' )],
303
- [DXB .p_tag ('DDD' )],
304
- ))
299
+ cell1 = DXB .table_cell (paragraph = DXB .p_tag ('AAA' ))
300
+ cell2 = DXB .table_cell (paragraph = DXB .p_tag ('CCC' ))
301
+ cell3 = DXB .table_cell (paragraph = DXB .p_tag ('BBB' ))
302
+ cell4 = DXB .table_cell (paragraph = DXB .p_tag ('DDD' ))
303
+ rows = [DXB .table_row ([cell1 , cell3 ]), DXB .table_row ([cell2 , cell4 ])]
304
+ table = DXB .table (rows )
305
+ body = table
306
+ xml = DXB .xml (body )
307
+ return xml
308
+
309
+
310
+ class RowSpanTestCase (_TranslationTestCase ):
311
+
312
+ expected_output = '''
313
+ <table border="1">
314
+ <tr>
315
+ <td rowspan="2">AAA</td>
316
+ <td>BBB</td>
317
+ </tr>
318
+ <tr>
319
+ <td>CCC</td>
320
+ </tr>
321
+ </table>
322
+ '''
323
+
324
+ def get_xml (self ):
325
+ cell1 = DXB .table_cell (
326
+ paragraph = DXB .p_tag ('AAA' ), merge = True , merge_continue = False )
327
+ cell2 = DXB .table_cell (
328
+ paragraph = DXB .p_tag (None ), merge = False , merge_continue = True )
329
+ cell3 = DXB .table_cell (paragraph = DXB .p_tag ('BBB' ))
330
+ cell4 = DXB .table_cell (paragraph = DXB .p_tag ('CCC' ))
331
+ rows = [DXB .table_row ([cell1 , cell3 ]), DXB .table_row ([cell2 , cell4 ])]
332
+ table = DXB .table (rows )
305
333
body = table
306
334
xml = DXB .xml (body )
307
335
return xml
@@ -333,18 +361,18 @@ class NestedTableTag(_TranslationTestCase):
333
361
'''
334
362
335
363
def get_xml (self ):
336
- nested_table = DXB .table ( num_rows = 2 , num_columns = 2 , text = chain (
337
- [ DXB .p_tag ('DDD' )],
338
- [ DXB .p_tag ('EEE' )],
339
- [ DXB .p_tag ('FFF' )],
340
- [ DXB .p_tag ( 'GGG' )],
341
- ) )
342
- table = DXB .table ( num_rows = 2 , num_columns = 2 , text = chain (
343
- [ DXB .p_tag ('AAA' )],
344
- [ DXB .p_tag ('BBB' )],
345
- [ DXB .p_tag ( 'CCC' )],
346
- [ nested_table ],
347
- ) )
364
+ cell1 = DXB .table_cell ( paragraph = DXB . p_tag ( 'DDD' ))
365
+ cell2 = DXB .table_cell ( paragraph = DXB . p_tag ('FFF' ))
366
+ cell3 = DXB .table_cell ( paragraph = DXB . p_tag ('EEE' ))
367
+ cell4 = DXB .table_cell ( paragraph = DXB . p_tag ('GGG' ))
368
+ rows = [ DXB . table_row ([ cell1 , cell3 ]), DXB .table_row ([ cell2 , cell4 ])]
369
+ nested_table = DXB . table ( rows )
370
+ cell1 = DXB .table_cell ( paragraph = DXB . p_tag ( 'AAA' ))
371
+ cell2 = DXB .table_cell ( paragraph = DXB . p_tag ('CCC' ))
372
+ cell3 = DXB .table_cell ( paragraph = DXB . p_tag ('BBB' ))
373
+ cell4 = DXB .table_cell ( nested_table )
374
+ rows = [ DXB . table_row ([ cell1 , cell3 ]), DXB . table_row ([ cell2 , cell4 ])]
375
+ table = DXB . table ( rows )
348
376
body = table
349
377
xml = DXB .xml (body )
350
378
return xml
@@ -365,14 +393,12 @@ class TableWithInvalidTag(_TranslationTestCase):
365
393
'''
366
394
367
395
def get_xml (self ):
368
- table = DXB .table (num_rows = 2 , num_columns = 2 , text = chain (
369
- [DXB .p_tag ('AAA' )],
370
- [DXB .p_tag ('BBB' )],
371
- # This tag may have CCC in it, however this tag has no meaning
372
- # pertaining to content.
373
- ['<w:invalidTag>CCC</w:invalidTag>' ],
374
- [DXB .p_tag ('DDD' )],
375
- ))
396
+ cell1 = DXB .table_cell (paragraph = DXB .p_tag ('AAA' ))
397
+ cell2 = DXB .table_cell ('<w:invalidTag>CCC</w:invalidTag>' )
398
+ cell3 = DXB .table_cell (paragraph = DXB .p_tag ('BBB' ))
399
+ cell4 = DXB .table_cell (paragraph = DXB .p_tag ('DDD' ))
400
+ rows = [DXB .table_row ([cell1 , cell3 ]), DXB .table_row ([cell2 , cell4 ])]
401
+ table = DXB .table (rows )
376
402
body = table
377
403
xml = DXB .xml (body )
378
404
return xml
@@ -410,9 +436,9 @@ def get_xml(self):
410
436
td = ''
411
437
for el in els :
412
438
td += el
413
- table = DXB .table ( num_rows = 1 , num_columns = 1 , text = chain (
414
- [ td ],
415
- ) )
439
+ cell1 = DXB .table_cell ( td )
440
+ row = DXB . table_row ([ cell1 ])
441
+ table = DXB . table ([ row ] )
416
442
body = table
417
443
xml = DXB .xml (body )
418
444
return xml
@@ -495,12 +521,12 @@ class ListWithContinuationTestCase(_TranslationTestCase):
495
521
'''
496
522
497
523
def get_xml (self ):
498
- table = DXB .table ( num_rows = 2 , num_columns = 2 , text = chain (
499
- [ DXB .p_tag ('DDD' )],
500
- [ DXB .p_tag ('EEE' )],
501
- [ DXB .p_tag ('FFF' )],
502
- [ DXB .p_tag ( 'GGG' )],
503
- ) )
524
+ cell1 = DXB .table_cell ( paragraph = DXB . p_tag ( 'DDD' ))
525
+ cell2 = DXB .table_cell ( paragraph = DXB . p_tag ('FFF' ))
526
+ cell3 = DXB .table_cell ( paragraph = DXB . p_tag ('EEE' ))
527
+ cell4 = DXB .table_cell ( paragraph = DXB . p_tag ('GGG' ))
528
+ rows = [ DXB . table_row ([ cell1 , cell3 ]), DXB .table_row ([ cell2 , cell4 ])]
529
+ table = DXB . table ( rows )
504
530
tags = [
505
531
DXB .li (text = 'AAA' , ilvl = 0 , numId = 1 ),
506
532
DXB .p_tag ('BBB' ),
@@ -536,12 +562,12 @@ class ListWithMultipleContinuationTestCase(_TranslationTestCase):
536
562
'''
537
563
538
564
def get_xml (self ):
539
- table1 = DXB .table ( num_rows = 1 , num_columns = 1 , text = chain (
540
- [ DXB .p_tag ( 'BBB' )],
541
- ) )
542
- table2 = DXB .table ( num_rows = 1 , num_columns = 1 , text = chain (
543
- [ DXB .p_tag ( 'CCC' )],
544
- ) )
565
+ cell = DXB .table_cell ( paragraph = DXB . p_tag ( 'BBB' ))
566
+ row = DXB .table_row ([ cell ])
567
+ table1 = DXB . table ([ row ] )
568
+ cell = DXB .table_cell ( paragraph = DXB . p_tag ( 'CCC' ))
569
+ row = DXB .table_row ([ cell ])
570
+ table2 = DXB . table ([ row ] )
545
571
tags = [
546
572
DXB .li (text = 'AAA' , ilvl = 0 , numId = 1 ),
547
573
table1 ,
@@ -648,12 +674,12 @@ class DeeplyNestedTableTestCase(_TranslationTestCase):
648
674
run_expected_output = False
649
675
650
676
def get_xml (self ):
651
- table = DXB .p_tag ('AAA' )
677
+ paragraph = DXB .p_tag ('AAA' )
652
678
653
679
for _ in range (50 ):
654
- table = DXB .table ( num_rows = 1 , num_columns = 1 , text = chain (
655
- [ table ],
656
- ) )
680
+ cell = DXB .table_cell ( paragraph )
681
+ row = DXB . table_cell ([ cell ])
682
+ table = DXB . table ([ row ] )
657
683
body = table
658
684
xml = DXB .xml (body )
659
685
return xml
@@ -816,19 +842,20 @@ class SimpleTableTest(_TranslationTestCase):
816
842
</table>'''
817
843
818
844
def get_xml (self ):
819
- table = DXB .table (num_rows = 3 , num_columns = 3 , text = chain (
820
- [DXB .p_tag ('Blank' )],
821
- [DXB .p_tag ('Column 1' )],
822
- [DXB .p_tag ('Column 2' )],
823
- [DXB .p_tag ('Row 1' )],
824
- [DXB .p_tag ('First' )],
825
- [DXB .p_tag ('Second' )],
826
- [DXB .p_tag ('Row 2' )],
827
- [DXB .p_tag ('Third' )],
828
- [DXB .p_tag ('Fourth' )],
829
- ), merge = True )
845
+ cell1 = DXB .table_cell (paragraph = DXB .p_tag ('Blank' ))
846
+ cell2 = DXB .table_cell (paragraph = DXB .p_tag ('Row 1' ))
847
+ cell3 = DXB .table_cell (paragraph = DXB .p_tag ('Row 2' ))
848
+ cell4 = DXB .table_cell (paragraph = DXB .p_tag ('Column 1' ))
849
+ cell5 = DXB .table_cell (paragraph = DXB .p_tag ('First' ))
850
+ cell6 = DXB .table_cell (paragraph = DXB .p_tag ('Third' ))
851
+ cell7 = DXB .table_cell (paragraph = DXB .p_tag ('Column 2' ))
852
+ cell8 = DXB .table_cell (paragraph = DXB .p_tag ('Second' ))
853
+ cell9 = DXB .table_cell (paragraph = DXB .p_tag ('Fourth' ))
854
+ rows = [DXB .table_row ([cell1 , cell4 , cell7 ]),
855
+ DXB .table_row ([cell2 , cell5 , cell8 ]),
856
+ DXB .table_row ([cell3 , cell6 , cell9 ])]
857
+ table = DXB .table (rows )
830
858
body = table
831
-
832
859
xml = DXB .xml (body )
833
860
return xml
834
861
@@ -889,15 +916,14 @@ def get_xml(self):
889
916
lis = ''
890
917
for text , ilvl , numId in li_text :
891
918
lis += DXB .li (text = text , ilvl = ilvl , numId = numId )
892
- table = DXB .table ( num_rows = 1 , num_columns = 1 , text = chain (
893
- [ lis ],
894
- ) )
919
+ cell1 = DXB .table_cell ( lis )
920
+ rows = DXB . table_row ([ cell1 ])
921
+ table = DXB . table ([ rows ] )
895
922
lis = ''
896
923
lis += DXB .li (text = 'AAA' , ilvl = 0 , numId = 1 )
897
924
lis += table
898
925
lis += DXB .li (text = 'CCC' , ilvl = 0 , numId = 1 )
899
926
body = lis
900
-
901
927
xml = DXB .xml (body )
902
928
return xml
903
929
@@ -931,6 +957,7 @@ class HeadingTestCase(_TranslationTestCase):
931
957
<h6>GGG</h6>
932
958
<p>HHH</p>
933
959
'''
960
+
934
961
styles_dict = {
935
962
'style0' : 'heading 1' ,
936
963
'style1' : 'heading 2' ,
0 commit comments