def test_get_set(self): cd = ConfigDict() self.assertRaises(KeyError, cd.get, b"foo", b"core") cd.set((b"core", ), b"foo", b"bla") self.assertEqual(b"bla", cd.get((b"core", ), b"foo")) cd.set((b"core", ), b"foo", b"bloe") self.assertEqual(b"bloe", cd.get((b"core", ), b"foo"))
def test_dict(self): cd = ConfigDict() cd.set((b"core", ), b"foo", b"bla") cd.set((b"core2", ), b"foo", b"bloe") self.assertEqual([(b"core", ), (b"core2", )], list(cd.keys())) self.assertEqual(cd[(b"core", )], {b'foo': b'bla'}) cd[b'a'] = b'b' self.assertEqual(cd[b'a'], b'b')
def test_config_proxy(self): config = ConfigDict() config.set(b'http', b'proxy', b'http://localhost:3128/') manager = default_urllib3_manager(config=config) self.assertIsInstance(manager, urllib3.ProxyManager) self.assertTrue(hasattr(manager, 'proxy')) self.assertEqual(manager.proxy.scheme, 'http') self.assertEqual(manager.proxy.host, 'localhost') self.assertEqual(manager.proxy.port, 3128)
def test_get_boolean(self): cd = ConfigDict() cd.set((b"core", ), b"foo", b"true") self.assertTrue(cd.get_boolean((b"core", ), b"foo")) cd.set((b"core", ), b"foo", b"false") self.assertFalse(cd.get_boolean((b"core", ), b"foo")) cd.set((b"core", ), b"foo", b"invalid") self.assertRaises(ValueError, cd.get_boolean, (b"core", ), b"foo")
def test_itersections(self): cd = ConfigDict() cd.set((b"core2", ), b"foo", b"bloe") self.assertEqual([(b"core2", )], list(cd.itersections()))
def test_iteritems_nonexistant(self): cd = ConfigDict() cd.set((b"core2", ), b"foo", b"bloe") self.assertEqual([], list(cd.iteritems((b"core", ))))
def test_iteritems(self): cd = ConfigDict() cd.set((b"core", ), b"foo", b"bla") cd.set((b"core2", ), b"foo", b"bloe") self.assertEqual([(b'foo', b'bla')], list(cd.iteritems((b"core", ))))
def test_config_no_ssl(self): config = ConfigDict() config.set(b'http', b'sslVerify', b'false') manager = default_urllib3_manager(config=config) self.assertEqual(manager.connection_pool_kw['cert_reqs'], 'CERT_NONE')