140
141
def test_help_topic(self):
141
142
topics = help_topics.HelpTopicRegistry()
142
topics.register('formats', self.make_format_registry().help_topic,
144
topic = topics.get_detail('formats')
145
new, rest = topic.split('Experimental formats')
143
registry = self.make_format_registry()
144
topics.register('current-formats', registry.help_topic,
146
topics.register('other-formats', registry.help_topic,
148
new = topics.get_detail('current-formats')
149
rest = topics.get_detail('other-formats')
146
150
experimental, deprecated = rest.split('Deprecated formats')
147
self.assertContainsRe(new, 'These formats can be used')
151
self.assertContainsRe(new, 'bzr help formats')
148
152
self.assertContainsRe(new,
149
153
':knit:\n \(native\) \(default\) Format using knits\n')
150
154
self.assertContainsRe(experimental,
1075
1079
run, its implementation being incomplete.
1078
# Should be defined by daughter classes to ensure redirection
1079
# still use the same transport implementation (not currently
1080
# enforced as it's a bit tricky to get right (see the FIXME
1081
# in BzrDir.open_from_transport for the unique use case so
1085
1082
def create_transport_readonly_server(self):
1086
return HTTPServerRedirecting()
1083
return http_utils.HTTPServerRedirecting()
1088
1085
def create_transport_secondary_server(self):
1089
return HTTPServerRedirecting()
1086
return http_utils.HTTPServerRedirecting()
1091
1088
def setUp(self):
1092
# Both servers redirect to each server creating a loop
1093
super(TestHTTPRedirectionLoop, self).setUp()
1089
super(TestHTTPRedirections, self).setUp()
1094
1090
# The redirections will point to the new server
1095
1091
self.new_server = self.get_readonly_server()
1096
1092
# The requests to the old server will be redirected
1097
1093
self.old_server = self.get_secondary_server()
1098
1094
# Configure the redirections
1099
1095
self.old_server.redirect_to(self.new_server.host, self.new_server.port)
1097
def test_loop(self):
1098
# Both servers redirect to each other creating a loop
1100
1099
self.new_server.redirect_to(self.old_server.host, self.old_server.port)
1102
def _qualified_url(self, host, port):
1103
return 'http+%s://%s:%s' % (self._qualifier, host, port)
1105
def test_loop(self):
1106
1100
# Starting from either server should loop
1107
old_url = self._qualified_url(self.old_server.host,
1101
old_url = self._qualified_url(self.old_server.host,
1108
1102
self.old_server.port)
1109
1103
oldt = self._transport(old_url)
1110
1104
self.assertRaises(errors.NotBranchError,
1111
1105
bzrdir.BzrDir.open_from_transport, oldt)
1112
new_url = self._qualified_url(self.new_server.host,
1106
new_url = self._qualified_url(self.new_server.host,
1113
1107
self.new_server.port)
1114
1108
newt = self._transport(new_url)
1115
1109
self.assertRaises(errors.NotBranchError,
1116
1110
bzrdir.BzrDir.open_from_transport, newt)
1119
class TestHTTPRedirections_urllib(TestHTTPRedirectionLoop,
1120
TestCaseWithTwoWebservers):
1112
def test_qualifier_preserved(self):
1113
wt = self.make_branch_and_tree('branch')
1114
old_url = self._qualified_url(self.old_server.host,
1115
self.old_server.port)
1116
start = self._transport(old_url).clone('branch')
1117
bdir = bzrdir.BzrDir.open_from_transport(start)
1118
# Redirection should preserve the qualifier, hence the transport class
1120
self.assertIsInstance(bdir.root_transport, type(start))
1123
class TestHTTPRedirections_urllib(TestHTTPRedirections,
1124
http_utils.TestCaseWithTwoWebservers):
1121
1125
"""Tests redirections for urllib implementation"""
1123
_qualifier = 'urllib'
1124
1127
_transport = HttpTransport_urllib
1129
def _qualified_url(self, host, port):
1130
return 'http+urllib://%s:%s' % (host, port)
1128
1134
class TestHTTPRedirections_pycurl(TestWithTransport_pycurl,
1129
TestHTTPRedirectionLoop,
1130
TestCaseWithTwoWebservers):
1135
TestHTTPRedirections,
1136
http_utils.TestCaseWithTwoWebservers):
1131
1137
"""Tests redirections for pycurl implementation"""
1133
_qualifier = 'pycurl'
1139
def _qualified_url(self, host, port):
1140
return 'http+pycurl://%s:%s' % (host, port)
1143
class TestHTTPRedirections_nosmart(TestHTTPRedirections,
1144
http_utils.TestCaseWithTwoWebservers):
1145
"""Tests redirections for the nosmart decorator"""
1147
_transport = NoSmartTransportDecorator
1149
def _qualified_url(self, host, port):
1150
return 'nosmart+http://%s:%s' % (host, port)
1153
class TestHTTPRedirections_readonly(TestHTTPRedirections,
1154
http_utils.TestCaseWithTwoWebservers):
1155
"""Tests redirections for readonly decoratror"""
1157
_transport = ReadonlyTransportDecorator
1159
def _qualified_url(self, host, port):
1160
return 'readonly+http://%s:%s' % (host, port)
1136
1163
class TestDotBzrHidden(TestCaseWithTransport):