~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/codehosting/tests/test_acceptance.py

  • Committer: Colin Watson
  • Date: 2011-08-19 00:25:11 UTC
  • mfrom: (7675.1045.728 db-devel)
  • mto: This revision was merged to the branch mainline in revision 13909.
  • Revision ID: cjwatson@canonical.com-20110819002511-0x8hrqs1ckiqk53g
merge db-devel

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
from lp.code.enums import BranchType
36
36
from lp.code.interfaces.branch import IBranchSet
37
37
from lp.code.interfaces.branchnamespace import get_branch_namespace
 
38
from lp.code.tests.helpers import (
 
39
    get_non_existant_source_package_branch_unique_name,
 
40
    )
38
41
from lp.codehosting import (
39
42
    get_bzr_path,
40
43
    get_BZR_PLUGIN_PATH_for_subprocess,
56
59
 
57
60
 
58
61
class ForkingServerForTests(object):
59
 
    """Map starting/stopping a LPForkingService with setUp() and tearDown()."""
 
62
    """Map starting/stopping a LPForkingService to setUp() and tearDown()."""
60
63
 
61
64
    def __init__(self):
62
65
        self.process = None
68
71
        env = os.environ.copy()
69
72
        env['BZR_PLUGIN_PATH'] = BZR_PLUGIN_PATH
70
73
        # TODO: We probably want to use a random disk path for
71
 
        #       forking_daemon_socket, but we need to update config so that the
72
 
        #       CodeHosting service can find it.
 
74
        #       forking_daemon_socket, but we need to update config so that
 
75
        #       the CodeHosting service can find it.
73
76
        #       The main problem is that CodeHostingTac seems to start a tac
74
77
        #       server directly from the disk configs, and doesn't use the
75
78
        #       in-memory config. So we can't just override the memory
83
86
        self.process = process
84
87
        # Wait for it to indicate it is running
85
88
        # The first line should be "Preloading" indicating it is ready
86
 
        preloading_line = process.stderr.readline()
 
89
        process.stderr.readline()
87
90
        # The next line is the "Listening on socket" line
88
 
        socket_line = process.stderr.readline()
 
91
        process.stderr.readline()
89
92
        # Now it is ready
90
93
 
91
94
    def tearDown(self):
92
 
        # SIGTERM is the graceful exit request, potentially we could wait a bit
93
 
        # and send something stronger?
 
95
        # SIGTERM is the graceful exit request, potentially we could wait a
 
96
        # bit and send something stronger?
94
97
        if self.process is not None and self.process.poll() is None:
95
98
            os.kill(self.process.pid, signal.SIGTERM)
96
99
            self.process.wait()
102
105
            os.remove(self.socket_path)
103
106
 
104
107
 
105
 
 
106
108
class SSHServerLayer(ZopelessAppServerLayer):
107
109
 
108
110
    _tac_handler = None
611
613
            self.local_branch_path, remote_url,
612
614
            ['Permission denied:', 'Transport operation not possible:'])
613
615
 
 
616
    def test_push_new_branch_of_non_existant_source_package_name(self):
 
617
        ZopelessAppServerLayer.txn.begin()
 
618
        unique_name = get_non_existant_source_package_branch_unique_name(
 
619
            'testuser', self.factory)
 
620
        ZopelessAppServerLayer.txn.commit()
 
621
        remote_url = self.getTransportURL(unique_name)
 
622
        self.push(self.local_branch_path, remote_url)
 
623
        self.assertBranchesMatch(self.local_branch_path, remote_url)
 
624
 
614
625
    def test_can_push_loom_branch(self):
615
626
        # We can push and pull a loom branch.
616
627
        self.makeLoomBranchAndTree('loom')
696
707
        urllib2.urlopen(web_status_url)
697
708
 
698
709
 
699
 
 
700
710
def make_server_tests(base_suite, servers):
701
711
    from lp.codehosting.tests.helpers import (
702
712
        CodeHostingTestProviderAdapter)