@@ -331,7 +331,10 @@ def test_DeltaCode_to_dict_simple_unmodified(self):
331331 ('unmodified' , [
332332 OrderedDict ([
333333 ('category' , 'unmodified' ),
334- ('path' , u'test/unmodified.txt' )
334+ ('path' , u'test/unmodified.txt' ),
335+ ('name' , u'unmodified.txt' ),
336+ ('type' , u'file' ),
337+ ('size' , 11 )
335338 ])
336339 ])
337340 ])
@@ -593,9 +596,13 @@ def test_Delta_to_dict_removed(self):
593596 'sha1' : 'a' ,
594597 'original_path' : ''
595598 })
599+
596600 expected = {
597601 'category' : 'removed' ,
598- 'path' : 'path/removed.txt'
602+ 'path' : 'path/removed.txt' ,
603+ 'name' : 'removed.txt' ,
604+ 'type' : 'file' ,
605+ 'size' : 20
599606 }
600607
601608 delta = deltacode .Delta (None , old , 'removed' )
@@ -611,9 +618,13 @@ def test_Delta_to_dict_added(self):
611618 'sha1' : 'a' ,
612619 'original_path' : ''
613620 })
621+
614622 expected = {
615623 'category' : 'added' ,
616- 'path' : 'path/added.txt'
624+ 'path' : 'path/added.txt' ,
625+ 'name' : 'added.txt' ,
626+ 'type' : 'file' ,
627+ 'size' : 20
617628 }
618629
619630 delta = deltacode .Delta (new , None , 'added' )
@@ -640,7 +651,10 @@ def test_Delta_to_dict_modified(self):
640651
641652 expected = {
642653 'category' : 'modified' ,
643- 'path' : 'path/modified.txt'
654+ 'path' : 'path/modified.txt' ,
655+ 'name' : 'modified.txt' ,
656+ 'type' : 'file' ,
657+ 'size' : 20
644658 }
645659
646660 delta = deltacode .Delta (new , old , 'modified' )
@@ -667,7 +681,10 @@ def test_Delta_to_dict_unmodified(self):
667681
668682 expected = {
669683 'category' : 'unmodified' ,
670- 'path' : 'path/unmodified.txt'
684+ 'path' : 'path/unmodified.txt' ,
685+ 'name' : 'unmodified.txt' ,
686+ 'type' : 'file' ,
687+ 'size' : 20
671688 }
672689
673690 delta = deltacode .Delta (new , old , 'unmodified' )
@@ -677,7 +694,74 @@ def test_Delta_to_dict_unmodified(self):
677694 def test_Delta_to_dict_empty (self ):
678695 delta = deltacode .Delta ()
679696
680- assert delta .to_dict () == OrderedDict ([('category' , 'unmodified' ), ('path' , '' )])
697+ assert delta .to_dict () == OrderedDict ([('category' , 'unmodified' ), ('path' , '' ), ('name' , '' ), ('type' , '' ), ('size' , '' )])
698+
699+ def test_Delta_to_dict_license_modified (self ):
700+ new_scan = self .get_test_loc ('deltacode/scan_modified_new_license_added.json' )
701+ old_scan = self .get_test_loc ('deltacode/scan_modified_old_license_added.json' )
702+
703+ result = DeltaCode (new_scan , old_scan )
704+
705+ expected = OrderedDict ([
706+ ('added' , []),
707+ ('removed' , []),
708+ ('modified' , [
709+ OrderedDict ([
710+ ('category' , 'modified' ),
711+ ('path' , u'some/path/c/c1.py' ),
712+ ('name' , u'c1.py' ),
713+ ('type' , u'file' ),
714+ ('size' , 300 )
715+ ]),
716+ OrderedDict ([
717+ ('category' , 'license change' ),
718+ ('path' , u'some/path/a/a1.py' ),
719+ ('name' , u'a1.py' ),
720+ ('type' , u'file' ),
721+ ('size' , 300 )
722+ ]),
723+ OrderedDict ([
724+ ('category' , 'license change' ),
725+ ('path' , u'some/path/b/b1.py' ),
726+ ('name' , u'b1.py' ),
727+ ('type' , u'file' ),
728+ ('size' , 300 )
729+ ])
730+ ]),
731+ ('unmodified' , [])
732+ ])
733+
734+ assert result .to_dict () == expected
735+
736+ def test_Delta_to_dict_no_license_key_value (self ):
737+ new_scan = self .get_test_loc ('deltacode/scan_modified_new_no_license_key.json' )
738+ old_scan = self .get_test_loc ('deltacode/scan_modified_old_no_license_key.json' )
739+
740+ result = DeltaCode (new_scan , old_scan )
741+
742+ expected = OrderedDict ([
743+ ('added' , []),
744+ ('removed' , []),
745+ ('modified' , [
746+ OrderedDict ([
747+ ('category' , 'modified' ),
748+ ('path' , u'some/path/a/a1.py' ),
749+ ('name' , u'a1.py' ),
750+ ('type' , u'file' ),
751+ ('size' , 250 )
752+ ]),
753+ OrderedDict ([
754+ ('category' , 'modified' ),
755+ ('path' , u'some/path/b/b1.py' ),
756+ ('name' , u'b1.py' ),
757+ ('type' , u'file' ),
758+ ('size' , 310 )
759+ ])
760+ ]),
761+ ('unmodified' , [])
762+ ])
763+
764+ assert result .to_dict () == expected
681765
682766 def test_Delta_create_object_removed (self ):
683767 new = None
0 commit comments