Пример #1
0
    def test_try_value_to_bool_not_strict(self):
        true_values = (True, 'True', 'true', 'TRUE', 'tRUE', 'On', 'ON', 'on',
                       'oN', 'Yes', 'YES', 'yes')
        for v in true_values:
            self.assertEqual(True, utils.try_value_to_bool(v,
                                                           strict_mode=False))

        false_values = (False, 'False', 'false', 'FALSE', 'fALSE', 'Off',
                        'OFF', 'off', 'No', 'NO', 'no')
        for v in false_values:
            self.assertEqual(False,
                             utils.try_value_to_bool(v, strict_mode=False))

        unchanged_values = ('/path/to/file', 'YES!', '/tmp/certificate')
        for v in unchanged_values:
            self.assertEqual(v, utils.try_value_to_bool(v, strict_mode=False))
Пример #2
0
 def test_try_value_to_bool(self):
     test_data = ((True, True), (False, False), (str(True), True),
                  (str(False), False), ('True', True), ('False', False),
                  ('TRUE', 'TRUE'), ('FALSE', 'FALSE'), ('/path/to/file',
                                                         '/path/to/file'))
     for value, result in test_data:
         self.assertEqual(result, utils.try_value_to_bool(value))
Пример #3
0
 def from_dict(cls, eas_from_nios):
     """Converts extensible attributes from the NIOS reply."""
     if not eas_from_nios:
         return
     return cls(
         {name: ib_utils.try_value_to_bool(eas_from_nios[name]['value'])
          for name in eas_from_nios})
    def test_try_value_to_bool_not_strict(self):
        true_values = (True, 'True', 'true', 'TRUE', 'tRUE',
                       'On', 'ON', 'on', 'oN',
                       'Yes', 'YES', 'yes')
        for v in true_values:
            self.assertEqual(True,
                             utils.try_value_to_bool(v, strict_mode=False))

        false_values = (False, 'False', 'false', 'FALSE', 'fALSE',
                        'Off', 'OFF', 'off',
                        'No', 'NO', 'no')
        for v in false_values:
            self.assertEqual(False,
                             utils.try_value_to_bool(v, strict_mode=False))

        unchanged_values = ('/path/to/file', 'YES!', '/tmp/certificate')
        for v in unchanged_values:
            self.assertEqual(v, utils.try_value_to_bool(v, strict_mode=False))
 def test_try_value_to_bool(self):
     test_data = ((True, True),
                  (False, False),
                  (str(True), True),
                  (str(False), False),
                  ('True', True),
                  ('False', False),
                  ('TRUE', 'TRUE'),
                  ('FALSE', 'FALSE'),
                  ('/path/to/file', '/path/to/file'))
     for value, result in test_data:
         self.assertEqual(result, utils.try_value_to_bool(value))
Пример #6
0
    def _configure_session(self):
        self.session = requests.Session()
        adapter = requests.adapters.HTTPAdapter(
            pool_connections=self.http_pool_connections,
            pool_maxsize=self.http_pool_maxsize)
        self.session.mount('http://', adapter)
        self.session.mount('https://', adapter)
        self.session.auth = (self.username, self.password)
        self.session.verify = utils.try_value_to_bool(self.ssl_verify,
                                                      strict_mode=False)

        if self.silent_ssl_warnings:
            requests.packages.urllib3.disable_warnings()
    def _configure_session(self):
        self.session = requests.Session()
        adapter = requests.adapters.HTTPAdapter(
            pool_connections=self.http_pool_connections,
            pool_maxsize=self.http_pool_maxsize,
            max_retries=self.max_retries)
        self.session.mount('http://', adapter)
        self.session.mount('https://', adapter)
        self.session.auth = (self.username, self.password)
        self.session.verify = utils.try_value_to_bool(self.ssl_verify,
                                                      strict_mode=False)

        if self.silent_ssl_warnings:
            urllib3.disable_warnings()