~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/doc/bugattachments.txt

  • Committer: Curtis Hovey
  • Date: 2011-12-18 15:13:07 UTC
  • mto: This revision was merged to the branch mainline in revision 14547.
  • Revision ID: curtis.hovey@canonical.com-20111218151307-sdm2gzobt5tplbe0
Moved badges to lp.app.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
file or a screenshot.
8
8
 
9
9
Let's look at a bug that has no attachments:
10
 
    >>> from lp.testing import login
 
10
    >>> from canonical.launchpad.ftests import login
11
11
    >>> login("foo.bar@canonical.com")
12
12
 
13
13
    >>> from lp.services.messages.interfaces.message import IMessageSet
28
28
 
29
29
    >>> from StringIO import StringIO
30
30
 
31
 
    >>> from lp.testing.event import TestEventListener
 
31
    >>> from canonical.launchpad.ftests.event import TestEventListener
32
32
    >>> from lazr.lifecycle.event import IObjectCreatedEvent
33
33
    >>> def attachment_added(attachment, event):
34
34
    ...     print "Attachment added: %r" % attachment.libraryfile.filename
117
117
attachment needs to handle that:
118
118
 
119
119
    >>> from zope.component import getMultiAdapter
120
 
    >>> from lp.services.webapp.servers import LaunchpadTestRequest
 
120
    >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
121
121
 
122
122
    >>> login('test@canonical.com')
123
123
    >>> filecontent = StringIO('')
173
173
If we set the limit to 0 we can upload it, though, since a value of 0
174
174
means no limit:
175
175
 
176
 
    >>> from lp.services.config import config
 
176
    >>> from canonical.config import config
177
177
    >>> max_attachment_size = """
178
178
    ...     [launchpad]
179
179
    ...     max_attachment_size: 0
400
400
    >>> bugs[0].id
401
401
    4
402
402
 
403
 
    >>> from lp.services.searchbuilder import any
 
403
    >>> from canonical.launchpad.searchbuilder import any
404
404
    >>> attachmenttype = any(*BugAttachmentType.items)
405
405
    >>> params = BugTaskSearchParams(attachmenttype=attachmenttype, user=None)
406
406
    >>> bugtasks = bugtaskset.search(params)
423
423
 
424
424
Let's make our attachment a patch and search again:
425
425
 
426
 
    >>> from lp.services.database.sqlbase import flush_database_updates
 
426
    >>> from canonical.database.sqlbase import flush_database_updates
427
427
    >>> login('test@canonical.com')
428
428
    >>> attachment.type = BugAttachmentType.PATCH
429
429
    >>> flush_database_updates()
537
537
"Adding bug attachments to private bugs" below.
538
538
 
539
539
 
540
 
    >>> from lp.services.librarian.interfaces import (
 
540
    >>> from canonical.launchpad.interfaces.librarian import (
541
541
    ...     ILibraryFileAliasSet)
542
542
 
543
543
    >>> file_content = "Hello, world"