Commits

Alex Willmer committed 83593df

Tests for Ticket.populate_from()

Comments (0)

Files changed (2)

trac/ticket/tests/links.py

                                                             'parent_child')
         self.env.config.set('ticket-links', 'children.blocks', 'true')
         self.env.config.set('ticket-links', 'children.label', 'Overridden')
+        self.env.config.set('ticket-links', 'parent.copy_fields',
+                                                            'summary, foo')
         self.env.config.set('ticket-links', 'oneway', 'refersto')
         self.req = Mock(href=self.env.href, authname='anonymous', tz=utc,
                         args=dict(action='dummy'))
         self.assertEqual(1, ticket.id)
         self.assertEqual('', ticket['dependent'])
         
+    def test_populate_from_linked_field(self):
+        ticket = self._create_a_ticket()
+        ticket.insert()
+        ticket = Ticket(self.env)
+        ticket.populate_from(1, link_field_name='children')
+        self.assertEqual('Foo', ticket['summary'])
+        self.assertEqual('#1', ticket['children'])
+        
     def test_save_retrieve_links(self):
         ticket = self._create_a_ticket()
         ticket.insert()

trac/ticket/tests/model.py

         self.assertEqual('on', ticket['cbon'])
         self.assertEqual('0', ticket['cboff'])
 
+    def test_populate_from_ticket(self):
+        self.env.config.set('ticket', 'default_copy_fields', 
+                            'summary, component')
+        ticket = self._create_a_ticket()
+        ticket.insert()
+        ticket = Ticket(self.env)
+        ticket.populate_from(1)
+        self.assertEqual('Foo', ticket['summary'])
+        ticket = Ticket(self.env)
+        ticket.populate_from(1, copy_field_names=['foo'])
+        self.assertEqual('This is a custom field', ticket['foo'])
+        
     def test_changelog(self):
         tkt_id = self._insert_ticket('Test', reporter='joe', component='foo',
                                      milestone='bar')