@@ -379,19 +379,21 @@ def test_convert_odml_file_property(self):
379
379
self .assertEqual (sec [0 ].find ("name" ).text , "Valid Property tags test" )
380
380
self .assertEqual (len (sec [0 ].findall ("property" )), 1 )
381
381
prop = sec [0 ].find ("property" )
382
- self .assertEqual (len (prop ), 5 )
382
+ self .assertEqual (len (prop ), 6 )
383
383
self .assertEqual (prop .find ("name" ).text , "Property name" )
384
384
self .assertEqual (prop .find ("type" ).text , "Property type" )
385
385
self .assertEqual (prop .find ("definition" ).text , "Property definition" )
386
386
self .assertEqual (prop .find ("dependency" ).text , "Property dependency" )
387
387
self .assertEqual (prop .find ("dependencyvalue" ).text , "Property dependency value" )
388
+ self .assertEqual (len (prop .findall ("id" )), 1 )
388
389
389
390
# Test non-import of Property w/o name
390
391
self .assertEqual (len (sec [1 ].findall ("property" )), 1 )
391
392
# Test absence of non-Property tags
392
393
prop = sec [1 ].find ("property" )
393
- self .assertEqual (len (prop ), 1 )
394
+ self .assertEqual (len (prop ), 2 )
394
395
self .assertEqual (len (prop .findall ("name" )), 1 )
396
+ self .assertEqual (len (prop .findall ("id" )), 1 )
395
397
396
398
def test_convert_odml_file_value (self ):
397
399
"""Test proper conversion of the odml.Value entity from
@@ -511,6 +513,22 @@ def test_convert_odml_file_value(self):
511
513
<value> 3 <type>int</type></value>
512
514
<name>testIntListWhiteSpace</name>
513
515
</property>
516
+
517
+ <property>
518
+ <name>Single value with UUID</name>
519
+ <value>1</value>
520
+ <id>aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa</id>
521
+ </property>
522
+
523
+ <property>
524
+ <name>Single value with none-UUID ID</name>
525
+ <id>1</id>
526
+ </property>
527
+
528
+ <property>
529
+ <name>Single value with empty ID</name>
530
+ <id></id>
531
+ </property>
514
532
515
533
</section>
516
534
</odML>
@@ -521,85 +539,118 @@ def test_convert_odml_file_value(self):
521
539
conv_doc = vc ._convert (vc ._parse_xml ())
522
540
root = conv_doc .getroot ()
523
541
sec = root .find ("section" )
524
- self .assertEqual (len (sec ), 14 )
542
+ self .assertEqual (len (sec ), 17 )
525
543
526
544
# Test single value export
527
545
prop = sec .findall ("property" )[0 ]
528
- self .assertEqual (len (prop ), 2 )
546
+ self .assertEqual (len (prop ), 3 )
529
547
self .assertEqual (prop .find ("value" ).text , "1" )
548
+ self .assertEqual (len (prop .findall ("id" )), 1 )
530
549
531
550
# Test multiple value export
532
551
prop = sec .findall ("property" )[1 ]
533
- self .assertEqual (len (prop ), 2 )
552
+ self .assertEqual (len (prop ), 3 )
534
553
self .assertEqual (prop .find ("value" ).text , "[1,2,3]" )
554
+ self .assertEqual (len (prop .findall ("id" )), 1 )
535
555
536
556
# Test empty value export
537
557
prop = sec .findall ("property" )[2 ]
538
- self .assertEqual (len (prop ), 1 )
558
+ self .assertEqual (len (prop ), 2 )
539
559
self .assertEqual (prop .find ("name" ).text , "Empty value export" )
560
+ self .assertEqual (len (prop .findall ("id" )), 1 )
540
561
541
562
# Test valid Value tags
542
563
prop = sec .findall ("property" )[3 ]
543
- self .assertEqual (len (prop ), 7 )
564
+ self .assertEqual (len (prop ), 8 )
544
565
self .assertEqual (prop .find ("value" ).text , "0.1" )
545
566
self .assertEqual (prop .find ("type" ).text , "float" )
546
567
self .assertEqual (prop .find ("uncertainty" ).text , "0.05" )
547
568
self .assertEqual (prop .find ("unit" ).text , "mV" )
548
569
self .assertEqual (prop .find ("value_origin" ).text , "raw.txt" )
549
570
self .assertEqual (prop .find ("reference" ).text , "Value reference" )
550
571
self .assertEqual (len (prop .findall ("filename" )), 0 )
572
+ self .assertEqual (len (prop .findall ("id" )), 1 )
551
573
552
574
# Test valid multiple Value tag export
553
575
prop = sec .findall ("property" )[4 ]
554
- self .assertEqual (len (prop ), 7 )
576
+ self .assertEqual (len (prop ), 8 )
555
577
self .assertEqual (prop .find ("value" ).text , "[0.1,0.2,3]" )
556
578
self .assertEqual (prop .find ("type" ).text , "float" )
557
579
self .assertEqual (prop .find ("uncertainty" ).text , "0.05" )
558
580
self .assertEqual (prop .find ("unit" ).text , "mV" )
559
581
self .assertEqual (prop .find ("value_origin" ).text , "raw.txt" )
560
582
self .assertEqual (prop .find ("reference" ).text , "Value reference" )
583
+ self .assertEqual (len (prop .findall ("id" )), 1 )
561
584
562
585
# Test non-export of invalid Value tags
563
586
prop = sec .findall ("property" )[5 ]
564
- self .assertEqual (len (prop ), 1 )
587
+ self .assertEqual (len (prop ), 2 )
565
588
self .assertEqual (len (prop .findall ("name" )), 1 )
589
+ self .assertEqual (len (prop .findall ("id" )), 1 )
566
590
567
591
# Test dtype 'binary' replacement
568
592
prop = sec .findall ("property" )[6 ]
569
593
self .assertEqual (prop .find ("name" ).text , "Unsupported binary value type replace" )
570
594
self .assertEqual (prop .find ("type" ).text , "text" )
595
+ self .assertEqual (len (prop .findall ("id" )), 1 )
571
596
prop = sec .findall ("property" )[7 ]
572
597
self .assertEqual (prop .find ("name" ).text , "Unsupported binary value dtype replace" )
573
598
self .assertEqual (prop .find ("type" ).text , "text" )
599
+ self .assertEqual (len (prop .findall ("id" )), 1 )
574
600
575
601
# Test single string value with commata
576
602
prop = sec .findall ("property" )[8 ]
577
603
self .assertEqual (prop .find ("name" ).text , "testSingleString" )
578
604
self .assertEqual (prop .find ("value" ).text ,
579
605
"Single, string, value, with, many, commata." )
606
+ self .assertEqual (len (prop .findall ("id" )), 1 )
580
607
581
608
# Test string list import
582
609
prop = sec .findall ("property" )[9 ]
583
610
self .assertEqual (prop .find ("name" ).text , "testStringList" )
584
611
self .assertEqual (prop .find ("value" ).text , "[A,B,C]" )
612
+ self .assertEqual (len (prop .findall ("id" )), 1 )
585
613
586
614
# Test single string values wrapping whitespace removal
587
615
prop = sec .findall ("property" )[10 ]
588
616
self .assertEqual (prop .find ("name" ).text , "testStringWhiteSpace" )
589
617
self .assertEqual (prop .find ("value" ).text ,
590
618
"Single string value with wrapping whitespace" )
619
+ self .assertEqual (len (prop .findall ("id" )), 1 )
591
620
592
621
# Test multiple string values with wrapping whitespace removal
593
622
prop = sec .findall ("property" )[11 ]
594
623
self .assertEqual (prop .find ("name" ).text , "testStringListWhiteSpace" )
595
624
self .assertEqual (prop .find ("value" ).text ,
596
625
"[Multiple Strings,with wrapping,Whitespace]" )
626
+ self .assertEqual (len (prop .findall ("id" )), 1 )
597
627
598
628
# Test multiple int values with wrapping whitespaces
599
629
prop = sec .findall ("property" )[12 ]
600
630
self .assertEqual (prop .find ("name" ).text , "testIntListWhiteSpace" )
601
631
self .assertEqual (prop .find ("type" ).text , "int" )
602
632
self .assertEqual (prop .find ("value" ).text , "[1,2,3]" )
633
+ self .assertEqual (len (prop .findall ("id" )), 1 )
634
+
635
+ # Test single value export
636
+ prop = sec .findall ("property" )[13 ]
637
+ self .assertEqual (len (prop ), 3 )
638
+ self .assertEqual (prop .find ("value" ).text , "1" )
639
+ self .assertEqual (len (prop .findall ("id" )), 1 )
640
+ self .assertEqual (prop .find ("id" ).text , "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" )
641
+
642
+ # Test single value export
643
+ prop = sec .findall ("property" )[14 ]
644
+ self .assertEqual (len (prop ), 2 )
645
+ self .assertEqual (len (prop .findall ("id" )), 1 )
646
+ self .assertNotEqual (prop .find ("id" ).text , "1" )
647
+
648
+ # Test single value export
649
+ prop = sec .findall ("property" )[15 ]
650
+ self .assertEqual (len (prop ), 2 )
651
+ self .assertEqual (len (prop .findall ("id" )), 1 )
652
+ self .assertNotEqual (prop .find ("id" ).text , "1" )
653
+
603
654
604
655
def test_parse_dict_document (self ):
605
656
# Test appending tags; not appending empty sections
0 commit comments