~salgado/launchpad/use-default-python-for-ec2

« back to all changes in this revision

Viewing changes to lib/lp/archiveuploader/tests/__init__.py

  • Committer: Guilherme Salgado
  • Date: 2010-05-03 14:05:59 UTC
  • mfrom: (10669.1.1 use-default-python)
  • Revision ID: salgado@canonical.com-20100503140559-c7ppsjriq863uf3f
merge from use-default-python branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
 
4
"""Tests for the archive uploader."""
 
5
 
 
6
from __future__ import with_statement
 
7
 
4
8
__metaclass__ = type
5
9
 
6
10
__all__ = ['datadir', 'getPolicy', 'insertFakeChangesFile',
25
29
        raise ValueError("Path is not relative: %s" % path)
26
30
    return os.path.join(here, 'data', path)
27
31
 
 
32
 
28
33
def insertFakeChangesFile(fileID, path=None):
29
34
    """Insert a fake changes file into the librarian.
30
35
 
34
39
    """
35
40
    if path is None:
36
41
        path = datadir("ed-0.2-21/ed_0.2-21_source.changes")
37
 
    changes_file_obj = open(path, 'r')
38
 
    test_changes_file = changes_file_obj.read()
39
 
    changes_file_obj.close()
 
42
    with open(path, 'r') as changes_file_obj:
 
43
        test_changes_file = changes_file_obj.read()
40
44
    fillLibrarianFile(fileID, content=test_changes_file)
41
45
 
 
46
 
42
47
def insertFakeChangesFileForAllPackageUploads():
43
48
    """Ensure all the PackageUpload records point to a valid changes file."""
44
49
    for id in set(pu.changesfile.id for pu in PackageUploadSet()):
53
58
        self.distroseries = distroseries
54
59
        self.buildid = buildid
55
60
 
 
61
 
56
62
def getPolicy(name='anything', distro='ubuntu', distroseries=None,
57
63
              buildid=None):
58
64
    """Build and return an Upload Policy for the given context."""