~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/supermirrorsftp/tests/helpers.py

  • Committer: James Henstridge
  • Date: 2007-03-15 02:27:17 UTC
  • mfrom: (3948 launchpad)
  • mto: This revision was merged to the branch mainline in revision 4227.
  • Revision ID: james.henstridge@canonical.com-20070315022717-02kmowmcm2amk5c4
merge from rocketfuel

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2007 Canonical Ltd.  All rights reserved.
 
2
 
 
3
"""Common helpers for supermirrorsftp tests."""
 
4
 
 
5
__metaclass__ = type
 
6
__all__ = ['AvatarTestCase']
 
7
 
 
8
import os
 
9
import shutil
 
10
 
 
11
from canonical.tests.test_twisted import TwistedTestCase
 
12
 
 
13
 
 
14
class AvatarTestCase(TwistedTestCase):
 
15
    """Base class for tests that need an SFTPOnlyAvatar with some basic sample
 
16
    data."""
 
17
    def setUp(self):
 
18
        self.tmpdir = self.mktemp()
 
19
        os.mkdir(self.tmpdir)
 
20
        # A basic user dict, 'alice' is a member of no teams (aside from the
 
21
        # user themself).
 
22
        self.aliceUserDict = {
 
23
            'id': 1,
 
24
            'name': 'alice',
 
25
            'teams': [{'id': 1, 'name': 'alice', 'initialBranches': []}],
 
26
        }
 
27
 
 
28
        # An slightly more complex user dict for a user, 'bob', who is also a
 
29
        # member of a team.
 
30
        self.bobUserDict = {
 
31
            'id': 2,
 
32
            'name': 'bob',
 
33
            'teams': [{'id': 2, 'name': 'bob', 'initialBranches': []},
 
34
                      {'id': 3, 'name': 'test-team', 'initialBranches': []}],
 
35
        }
 
36
 
 
37
    def tearDown(self):
 
38
        shutil.rmtree(self.tmpdir)
 
39
        
 
40
        # Remove test droppings in the current working directory from using
 
41
        # twisted.trial.unittest.TestCase.mktemp outside the trial test runner.
 
42
        tmpdir_root = self.tmpdir.split(os.sep, 1)[0]
 
43
        shutil.rmtree(tmpdir_root)
 
44
 
 
45
 
 
46
 
 
47