parameters: (self)
docstring: Test merge
docstring_summary: Test merge
docstring_tokens: Test merge
function: def test_merge(self):
          """Test merge"""
          # empty packet with non-empty, no metas
          pp2 = Packet()
          pp2.set('a', 1)
          pp2.set('b', 2)
          pp2.set_meta('pm1', 1)
          pp2.set_meta('am1', 1, 'a')
          self.doc.merge(pp2)
          self.assertEqual(self.doc.get_metas(), ({}, {}), 'Failed merge')
          self.assertEqual(self.doc.get_attributes(), {'a': [1], 'b': [2]}, 
              'Failed merge')
          
          # empty packet with non-empty, with metas
          self.doc = Packet()
          self.doc.merge(pp2, metas=True)
          self.assertEqual(self.doc.get_metas(), ({'pm1': 1}, {'a': {'am1': 1}}),
              'Failed merge')
          self.assertEqual(self.doc.get_attributes(), {'a': [1], 'b': [2]},
              'Failed merge')
          
          # non-empty with non-empty
          pp2.set('c', 3)
          pp2.set('a', 4)
          pp2.set_meta('pm2', 2)
          pp2.set_meta('am2', 2, 'c')
          pp2.set_meta('am1', 3, 'a')
          self.doc.merge(pp2, metas=True)
          self.assertEqual(self.doc.get_metas(), ({'pm1': 1, 'pm2': 2}, 
              {'a': {'am1': 3}, 'c': {'am2': 2}}), 'Failed merge')
          self.assertEqual(self.doc.get_attributes(), {'a': [4], 'b': [2], 
              'c': [3]}, 'Failed merge')
function_tokens: def test_merge ( self ) : # empty packet with non-empty, no metas pp2 = Packet ( ) pp2 . set ( 'a' , 1 ) pp2 . set ( 'b' , 2 ) pp2 . set_meta ( 'pm1' , 1 ) pp2 . set_meta ( 'am1' , 1 , 'a' ) self . doc . merge ( pp2 ) self . assertEqual ( self . doc . get_metas ( ) , ( { } , { } ) , 'Failed merge' ) self . assertEqual ( self . doc . get_attributes ( ) , { 'a' : [ 1 ] , 'b' : [ 2 ] } , 'Failed merge' ) # empty packet with non-empty, with metas self . doc = Packet ( ) self . doc . merge ( pp2 , metas = True ) self . assertEqual ( self . doc . get_metas ( ) , ( { 'pm1' : 1 } , { 'a' : { 'am1' : 1 } } ) , 'Failed merge' ) self . assertEqual ( self . doc . get_attributes ( ) , { 'a' : [ 1 ] , 'b' : [ 2 ] } , 'Failed merge' ) # non-empty with non-empty pp2 . set ( 'c' , 3 ) pp2 . set ( 'a' , 4 ) pp2 . set_meta ( 'pm2' , 2 ) pp2 . set_meta ( 'am2' , 2 , 'c' ) pp2 . set_meta ( 'am1' , 3 , 'a' ) self . doc . merge ( pp2 , metas = True ) self . assertEqual ( self . doc . get_metas ( ) , ( { 'pm1' : 1 , 'pm2' : 2 } , { 'a' : { 'am1' : 3 } , 'c' : { 'am2' : 2 } } ) , 'Failed merge' ) self . assertEqual ( self . doc . get_attributes ( ) , { 'a' : [ 4 ] , 'b' : [ 2 ] , 'c' : [ 3 ] } , 'Failed merge' )