~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_serve.py

  • Committer: John Arbash Meinel
  • Date: 2008-09-26 22:14:42 UTC
  • mto: This revision was merged to the branch mainline in revision 3747.
  • Revision ID: john@arbash-meinel.com-20080926221442-3r67j99sr9rwe9w0
Make message optional, don't check the memory flag directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
        self.assertEqual('', result[0])
58
58
        self.assertEqual('bzr: interrupted\n', result[1])
59
59
 
 
60
    def make_read_requests(self, branch):
 
61
        """Do some read only requests."""
 
62
        branch.lock_read()
 
63
        try:
 
64
            branch.repository.all_revision_ids()
 
65
            self.assertEqual(_mod_revision.NULL_REVISION,
 
66
                             _mod_revision.ensure_null(branch.last_revision()))
 
67
        finally:
 
68
            branch.unlock()
 
69
 
60
70
    def start_server_inet(self, extra_options=()):
61
71
        """Start a bzr server subprocess using the --inet option.
62
72
 
70
80
        # Connect to the server
71
81
        # We use this url because while this is no valid URL to connect to this
72
82
        # server instance, the transport needs a URL.
 
83
        url = 'bzr://localhost/'
73
84
        client_medium = medium.SmartSimplePipesClientMedium(
74
 
            process.stdout, process.stdin)
75
 
        transport = remote.RemoteTransport(
76
 
            'bzr://localhost/', medium=client_medium)
 
85
            process.stdout, process.stdin, url)
 
86
        transport = remote.RemoteTransport(url, medium=client_medium)
77
87
        return process, transport
78
88
 
79
89
    def start_server_port(self, extra_options=()):
107
117
 
108
118
        # We get a working branch
109
119
        branch = BzrDir.open_from_transport(transport).open_branch()
110
 
        branch.repository.get_revision_graph()
111
 
        self.assertEqual(_mod_revision.NULL_REVISION,
112
 
                         _mod_revision.ensure_null(branch.last_revision()))
 
120
        self.make_read_requests(branch)
113
121
        self.assertInetServerShutsdownCleanly(process)
114
122
 
115
123
    def test_bzr_serve_port_readonly(self):
127
135
 
128
136
        # Connect to the server
129
137
        branch = Branch.open(url)
130
 
 
131
 
        # We get a working branch
132
 
        branch.repository.get_revision_graph()
133
 
        self.assertEqual(_mod_revision.NULL_REVISION,
134
 
                         _mod_revision.ensure_null(branch.last_revision()))
135
 
 
 
138
        self.make_read_requests(branch)
136
139
        self.assertServerFinishesCleanly(process)
137
140
 
138
141
    def test_bzr_connect_to_bzr_ssh(self):
208
211
                path_to_branch = os.path.splitdrive(path_to_branch)[1]
209
212
            branch = Branch.open(
210
213
                'bzr+ssh://fred:secret@localhost:%d%s' % (port, path_to_branch))
211
 
            
212
 
            branch.repository.get_revision_graph()
213
 
            self.assertEqual(_mod_revision.NULL_REVISION,
214
 
                             _mod_revision.ensure_null(branch.last_revision()))
 
214
            self.make_read_requests(branch)
215
215
            # Check we can perform write operations
216
216
            branch.bzrdir.root_transport.mkdir('foo')
217
217
        finally: