def testCreateNewLinkedTicket(self): """Test the creation of a new linked ticket""" # Get db and handle the transaction db = self.teh.get_env().get_db_cnx() new = AgiloTicket(self.teh.get_env()) new[Key.SUMMARY] = 'This is a new ticket, never saved' new[Key.DESCRIPTION] = 'This will be created and linked in one shot ;-)' new[Key.TYPE] = Type.TASK self.assert_true(new.link_from(self.t1, db)) self.assert_not_none(new.insert(db=db)) # Now commit the link and the insert db.commit() # Check that has been linked self.assert_true(new.is_linked_from(self.t1)) self.assert_true(self.t1.is_linked_to(new)) # Now test the autoinsert and link of the agilo ticket new2 = AgiloTicket(self.teh.get_env(), t_type=Type.TASK) new2[Key.SUMMARY] = "This is a linked new ticket" new2[Key.DESCRIPTION] = "description" self.assert_true(self.t1.link_to(new2)) self.assert_true(new2.is_linked_from(self.t1)) self.assert_true(self.t1.is_linked_to(new2)) # Now test the link failure self.assert_false(new2.link_from(self.t1))