~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archivepublisher/tests/publishing-meta-data-files.txt

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2005-12-10 05:13:18 UTC
  • mfrom: (2894.1.5 trivial)
  • Revision ID: pqm@pqm.ubuntu.com-20051210051318-6808ebbdeefce2cb
[trivial] Update staging Gina config

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Publishing Meta-Data Custom Files
2
 
=================================
3
 
 
4
 
Meta-data custom files are published, unmodified, to a special area
5
 
outside the actual archive directory.  This is so that the files can be
6
 
seen even when the archive is private, and allows commercial customers
7
 
to browse contents for potential later purchase.
8
 
 
9
 
We can demonstrate this publishing behaviour by creating a
10
 
PackageUploadCustom object for a meta-data upload:
11
 
 
12
 
    >>> from canonical.launchpad.interfaces.librarian import (
13
 
    ...     ILibraryFileAliasSet)
14
 
    >>> from cStringIO import StringIO
15
 
    >>> from lp.services.log.logger import FakeLogger
16
 
    >>> from lp.registry.interfaces.distribution import IDistributionSet
17
 
    >>> from lp.soyuz.enums import PackageUploadCustomFormat
18
 
    >>> from lp.soyuz.interfaces.publishing import PackagePublishingPocket
19
 
    >>> from lp.soyuz.model.queue import PackageUploadCustom
20
 
 
21
 
    >>> bat = getUtility(IDistributionSet)['ubuntutest']['breezy-autotest']
22
 
    >>> ppa = factory.makeArchive(distribution=bat.distribution)
23
 
    >>> package_upload = bat.createQueueEntry(
24
 
    ...     pocket=PackagePublishingPocket.RELEASE, changesfilename="test",
25
 
    ...     changesfilecontent="test",
26
 
    ...     archive=ppa)
27
 
    >>> content = "test"
28
 
    >>> test_file = getUtility(
29
 
    ...     ILibraryFileAliasSet).create(
30
 
    ...         "testmeta", len(content), StringIO(content), "text/plain")
31
 
    >>> custom_upload = PackageUploadCustom()
32
 
    >>> custom_upload.customformat = PackageUploadCustomFormat.META_DATA
33
 
    >>> custom_upload.packageupload = package_upload
34
 
    >>> custom_upload.libraryfilealias = test_file
35
 
    >>> # commit so that the file is put in the librarian.
36
 
    >>> import transaction
37
 
    >>> transaction.commit()
38
 
 
39
 
Now we can publish the custom upload:
40
 
 
41
 
    >>> custom_upload.publish(logger=FakeLogger())
42
 
    DEBUG Publishing custom testmeta to ubuntutest/breezy-autotest
43
 
 
44
 
The custom file is just called "testmeta" with the contents "test".  It will
45
 
be published in a location of the scheme:
46
 
 
47
 
/<person_name>/meta/<ppa_name>/<filename>
48
 
 
49
 
    >>> import os
50
 
    >>> from lp.archivepublisher.config import getPubConfig
51
 
    >>> pub_config = getPubConfig(ppa)
52
 
    >>> ppa_root = pub_config.distroroot
53
 
    >>> final_destination = os.path.join(
54
 
    ...     ppa_root, ppa.owner.name, "meta", ppa.name)
55
 
    >>> published_file = os.path.join(
56
 
    ...     final_destination, "testmeta")
57
 
 
58
 
    >>> os.path.exists(published_file)
59
 
    True
60
 
 
61
 
    >>> with open(published_file, 'rb') as fp:
62
 
    ...     content = fp.read()
63
 
 
64
 
    >>> print content
65
 
    test