~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/librarian/smoketest.py

  • Committer: Jeroen Vermeulen
  • Date: 2011-10-16 08:16:47 UTC
  • mto: This revision was merged to the branch mainline in revision 14165.
  • Revision ID: jeroen.vermeulen@canonical.com-20111016081647-nb3ab4mv9wwr68z2
Lint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/python -S
2
2
#
3
 
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
3
# Copyright 2010-2011 Canonical Ltd.  This software is licensed under the
4
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5
5
 
6
6
"""Perform simple librarian operations to verify the current configuration.
11
11
import sys
12
12
import urllib
13
13
 
14
 
from zope.component import getUtility
15
14
import pytz
16
15
import transaction
 
16
from zope.component import getUtility
17
17
 
18
18
from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
19
19
 
24
24
 
25
25
 
26
26
def store_file(client):
 
27
    expiry_date = datetime.datetime.now(pytz.UTC) + FILE_LIFETIME
27
28
    file_id = client.addFile(
28
29
        'smoke-test-file', FILE_SIZE, StringIO(FILE_DATA), 'text/plain',
29
 
        expires=datetime.datetime.now(pytz.UTC)+FILE_LIFETIME)
 
30
        expires=expiry_date)
30
31
    # To be able to retrieve the file, we must commit the current transaction.
31
32
    transaction.commit()
32
33
    alias = getUtility(ILibraryFileAliasSet)[file_id]