~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
= PocketChroot =

PocketChroot records combine DistroArchSeries and a Chroot.

Chroot are identified per LibraryFileAlias and we offer three method
based on IDistroArchSeries to handle them: get, add and update.

  >>> from lp.services.librarian.interfaces import ILibraryFileAliasSet
  >>> from lp.registry.interfaces.distribution import IDistributionSet
  >>> from lp.registry.interfaces.pocket import PackagePublishingPocket


Grab a distroarchseries:

  >>> ubuntu = getUtility(IDistributionSet)['ubuntu']
  >>> hoary = ubuntu['hoary']
  >>> hoary_i386 = hoary['i386']

Grab some files to be used as Chroots (it doesn't really matter what
they are, they simply need to be provide ILFA interface):

  >>> chroot1 = getUtility(ILibraryFileAliasSet)[1]
  >>> chroot2 = getUtility(ILibraryFileAliasSet)[2]

Check if getPocketChroot returns None for unknown chroots:

  >>> p_chroot = hoary_i386.getPocketChroot()
  >>> print p_chroot
  None

Check if getChroot returns the 'default' argument on not found chroots:

  >>> hoary_i386.getChroot(default='duuuuh')
  'duuuuh'

Invoke addOrUpdateChroot for missing chroot, so it will insert a new
record in PocketChroot:

  >>> p_chroot = hoary_i386.addOrUpdateChroot(chroot=chroot1)
  >>> print p_chroot.id
  1
  >>> print p_chroot.distroarchseries.architecturetag
  i386
  >>> print p_chroot.chroot.id,
  1

Invoke addOrUpdateChroot on an existing PocketChroot, it will update
the chroot:

  >>> p_chroot = hoary_i386.addOrUpdateChroot(chroot=chroot2)
  >>> print p_chroot.id
  1
  >>> print p_chroot.distroarchseries.architecturetag
  i386
  >>> print p_chroot.chroot.id,
  2

Ensure chroot was updated by retriving it from DB again:

  >>> hoary_i386.getPocketChroot().chroot.id
  2

Check if getChroot returns the correspondent Chroot LFA instance for
valid chroots.

  >>> chroot = hoary_i386.getChroot()
  >>> chroot.id
  2

Force transaction commit in order to test DB constraints:

  >>> import transaction
  >>> transaction.commit()