~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/stories/webservice/xx-person-createppa.txt

[r=henninge][bug=814567] Allow certain users to create private PPAs
        over the API. This time for sure.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
= Creating a PPA =
2
2
 
 
3
  >>> from zope.component import getUtility
 
4
  >>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
 
5
  >>> from lp.testing import celebrity_logged_in
3
6
  >>> from lp.testing.sampledata import ADMIN_EMAIL
4
7
  >>> login(ADMIN_EMAIL)
5
8
  >>> owner = factory.makePerson()
58
61
  ...     ppa_owner['ppas_collection_link']).jsonBody())
59
62
  http://api.launchpad.dev/beta/~.../+archive/ppa
60
63
 
 
64
However, we can grant them commercial admin access:
 
65
 
 
66
  >>> with celebrity_logged_in('admin'):
 
67
  ...     comm = getUtility(ILaunchpadCelebrities).commercial_admin
 
68
  ...     comm.addMember(owner, comm.teamowner)
 
69
  (True, <DBItem TeamMembershipStatus.APPROVED, (2) Approved>)
 
70
 
 
71
Once they have commercial access, they can create private PPAs:
 
72
 
 
73
  >>> print ppa_owner_webservice.named_post(
 
74
  ...     ppa_owner['self_link'], 'createPPA', {}, name='secret',
 
75
  ...     displayname='My secret new PPA', description='Secretness!',
 
76
  ...     private=True,
 
77
  ...     )
 
78
  HTTP/1.1 201 Created
 
79
  Status: 201
 
80
  ...
 
81
  Location: http://api.launchpad.dev/.../+archive/secret
 
82
  ...
 
83
 
 
84
And the PPA appears in their list of PPAs:
 
85
 
 
86
  >>> print_self_link_of_entries(webservice.get(
 
87
  ...     ppa_owner['ppas_collection_link']).jsonBody())
 
88
  http://api.launchpad.dev/.../+archive/ppa
 
89
  http://api.launchpad.dev/.../+archive/secret
 
90
 
 
91
And the PPA is, of course, private:
 
92
 
 
93
  >>> ppa = ppa_owner_webservice.named_get(
 
94
  ...     ppa_owner['self_link'], 'getPPAByName', name='secret').jsonBody()
 
95
  >>> ppa['private']
 
96
  True