Changeset 325028c in trunk
- Timestamp:
- 2016-08-31T08:50:13Z (9 years ago)
- Branches:
- master
- Children:
- d47fc0f
- Parents:
- 72f17afa
- Location:
- src/allmydata
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/node.py ¶
r72f17afa r325028c 14 14 from allmydata.util.encodingutil import get_filesystem_encoding, quote_output 15 15 from allmydata.util import configutil 16 17 def _import_tor(): 18 # this exists to be overridden by unit tests 19 try: 20 from foolscap.connections import tor 21 return tor 22 except ImportError: # pragma: no cover 23 return None 24 25 def _import_i2p(): 26 try: 27 from foolscap.connections import i2p 28 return i2p 29 except ImportError: # pragma: no cover 30 return None 16 31 17 32 # Add our application versions to the data that Foolscap's LogPublisher … … 176 191 if not enabled: 177 192 return None 178 try: 179 from foolscap.connections import tor 180 except ImportError: 193 tor = _import_tor() 194 if not tor: 181 195 return None 182 196 … … 216 230 if not enabled: 217 231 return None 218 try: 219 from foolscap.connections import i2p 220 except ImportError: 232 i2p = _import_i2p() 233 if not i2p: 221 234 return None 222 235 … … 260 273 " uses unknown handler type '%s'" 261 274 % tcp_handler_name) 275 if not handlers[tcp_handler_name]: 276 raise ValueError("'tahoe.cfg [connections] tcp=' uses " 277 "unavailable/unimportable handler type '%s'. " 278 "Please pip install tahoe-lafs[%s] to fix." 279 % (tcp_handler_name, tcp_handler_name)) 262 280 self._default_connection_handlers["tcp"] = tcp_handler_name 263 281 -
TabularUnified src/allmydata/test/test_connections.py ¶
r72f17afa r325028c 30 30 self.assertEqual(h, None) 31 31 32 def test_unimportable(self): 33 n = FakeNode(BASECONFIG) 34 with mock.patch("allmydata.node._import_tor", return_value=None): 35 h = n._make_tor_handler() 36 self.assertEqual(h, None) 37 32 38 def test_default(self): 33 39 n = FakeNode(BASECONFIG) … … 108 114 n = FakeNode(BASECONFIG+"[i2p]\nenable = false\n") 109 115 h = n._make_i2p_handler() 116 self.assertEqual(h, None) 117 118 def test_unimportable(self): 119 n = FakeNode(BASECONFIG) 120 with mock.patch("allmydata.node._import_i2p", return_value=None): 121 h = n._make_i2p_handler() 110 122 self.assertEqual(h, None) 111 123 … … 205 217 self.assertEqual(n._default_connection_handlers["i2p"], "i2p") 206 218 219 def test_tor_unimportable(self): 220 n = FakeNode(BASECONFIG+"[connections]\ntcp = tor\n") 221 with mock.patch("allmydata.node._import_tor", return_value=None): 222 e = self.assertRaises(ValueError, n.init_connections) 223 self.assertEqual(str(e), 224 "'tahoe.cfg [connections] tcp='" 225 " uses unavailable/unimportable handler type 'tor'." 226 " Please pip install tahoe-lafs[tor] to fix.") 227 207 228 def test_unknown(self): 208 229 n = FakeNode(BASECONFIG+"[connections]\ntcp = unknown\n")
Note: See TracChangeset
for help on using the changeset viewer.