Esempio n. 1
0
 def test_boolean_parsing(self):
     for expected, value in (
             (None, None),
             (None, ''),
             (False, 0), (False, '0'),
             (False, 'f'), (False, 'F'), (False, 'False'),
             (False, 'n'), (False, 'N'), (False, 'No'),
             (True, 1), (True, '1'),
             (True, 'y'), (True, 'Y'), (True, 'Yes'),
     ):
         assert expected is to_bool(value)
Esempio n. 2
0
 def test_boolean_parsing(self):
     for expected, value in (
             (None, None),
             (None, ''),
             (False, 0), (False, '0'),
             (False, 'f'), (False, 'F'), (False, 'False'),
             (False, 'n'), (False, 'N'), (False, 'No'),
             (True, 1), (True, '1'),
             (True, 'y'), (True, 'Y'), (True, 'Yes'),
     ):
         assert expected is to_bool(value)
Esempio n. 3
0
 def test_boolean_parsing(self):
     for expected, value in (
         (None, None),
         (None, ""),
         (False, 0),
         (False, "0"),
         (False, "f"),
         (False, "F"),
         (False, "False"),
         (False, "n"),
         (False, "N"),
         (False, "No"),
         (True, 1),
         (True, "1"),
         (True, "y"),
         (True, "Y"),
         (True, "Yes"),
     ):
         assert expected is to_bool(value)
Esempio n. 4
0
    def get_connection_pool(self, params):
        """
        Given a connection parameters, return a new sentinel connection pool
        for them.
        """
        url = urlparse(params["url"])

        # explicitly set service_name and sentinel_manager for the
        # SentinelConnectionPool constructor since will be called by from_url
        cp_params = dict(params)
        cp_params.update(service_name=url.hostname, sentinel_manager=self._sentinel)
        pool = super().get_connection_pool(cp_params)

        # convert "is_master" to a boolean if set on the URL, otherwise if not
        # provided it defaults to True.
        is_master = parse_qs(url.query).get("is_master")
        if is_master:
            pool.is_master = to_bool(is_master[0])

        return pool