コード例 #1
0
 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")
コード例 #2
0
    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)
コード例 #3
0
 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"))
コード例 #4
0
    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')
コード例 #5
0
    def test_itersections(self):
        cd = ConfigDict()
        cd.set((b"core2", ), b"foo", b"bloe")

        self.assertEqual([(b"core2", )], list(cd.itersections()))
コード例 #6
0
    def test_iteritems_nonexistant(self):
        cd = ConfigDict()
        cd.set((b"core2", ), b"foo", b"bloe")

        self.assertEqual([], list(cd.iteritems((b"core", ))))
コード例 #7
0
    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", ))))
コード例 #8
0
 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')
コード例 #9
0
 def test_config_no_proxy(self):
     manager = default_urllib3_manager(config=ConfigDict())
     self.assertNotIsInstance(manager, urllib3.ProxyManager)