Esempio n. 1
0
 def test_as_expected_none(self):
     """
     If None is passed instead of a config, return None.
     """
     mock_config = None
     result = importer.clean_config_dict(mock_config)
     self.assertTrue(result is None)
Esempio n. 2
0
 def test_as_expected_no_trim(self):
     """
     If a config without None values is passed, it is not modified.
     """
     expected_clean_config = {'keep': 'this', 'also keep': 'this'}
     result = importer.clean_config_dict(expected_clean_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 3
0
 def test_as_expected_no_trim(self):
     """
     If a config without None values is passed, it is not modified.
     """
     expected_clean_config = {'keep': 'this', 'also keep': 'this'}
     result = importer.clean_config_dict(expected_clean_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 4
0
 def test_as_expected_none(self):
     """
     If None is passed instead of a config, return None.
     """
     mock_config = None
     result = importer.clean_config_dict(mock_config)
     self.assertTrue(result is None)
Esempio n. 5
0
 def test_feed_with_basic_auth_username(self):
     """
     Ensure that the username is moved to config even if password is not present.
     """
     mock_config = {'feed': 'http://[email protected]'}
     expected_clean_config = {'feed': 'http://realfeed.com', 'basic_auth_username': '******'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 6
0
 def test_as_expected_conf(self):
     """
     Ensure that keys whose value is None are removed.
     """
     mock_config = {'keep': 'this', 'Lose': None, 'Also lose': None, 'also keep': 'this'}
     expected_clean_config = {'keep': 'this', 'also keep': 'this'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 7
0
 def test_feed_with_basic_auth_username(self):
     """
     Ensure that the username is moved to config even if password is not present.
     """
     mock_config = {'feed': 'http://[email protected]'}
     expected_clean_config = {'feed': 'http://realfeed.com', 'basic_auth_username': '******'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 8
0
 def test_as_expected_conf(self):
     """
     Ensure that keys whose value is None are removed.
     """
     mock_config = {'keep': 'this', 'Lose': None, 'Also lose': None, 'also keep': 'this'}
     expected_clean_config = {'keep': 'this', 'also keep': 'this'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 9
0
 def test_as_expected_conf(self):
     """
     Ensure that keys whose value is None are removed.
     """
     mock_config = {"keep": "this", "Lose": None, "Also lose": None, "also keep": "this"}
     expected_clean_config = {"keep": "this", "also keep": "this"}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 10
0
 def test_feed_with_basic_auth_username_password_at_symbol(self):
     """
     Ensure that usernames and passwords can contain the '@' symbol.
     """
     mock_config = {'feed': 'http://mock%40user:mock%[email protected]'}
     expected_clean_config = {'feed': 'http://realfeed.com', 'basic_auth_username': '******',
                              'basic_auth_password': '******'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 11
0
 def test_feed_with_basic_auth_password(self):
     """
     If password but not username is in the feed, move the password config set username empty ''.
     """
     mock_config = {'feed': 'http://:[email protected]'}
     expected_clean_config = {'feed': 'http://realfeed.com', 'basic_auth_username': '',
                              'basic_auth_password': '******'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 12
0
 def test_feed_with_basic_auth_username_password(self):
     """
     Ensure that username and password are removed from the feed and put into the config.
     """
     mock_config = {'feed': 'http://*****:*****@realfeed.com'}
     expected_clean_config = {'feed': 'http://realfeed.com', 'basic_auth_username': '******',
                              'basic_auth_password': '******'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 13
0
 def test_feed_with_basic_auth_username_password_at_symbol(self):
     """
     Ensure that usernames and passwords can contain the '@' symbol.
     """
     mock_config = {'feed': 'http://mock@user:mock@[email protected]'}
     expected_clean_config = {'feed': 'http://realfeed.com', 'basic_auth_username': '******',
                              'basic_auth_password': '******'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 14
0
 def test_feed_with_basic_auth_password(self):
     """
     If password but not username is in the feed, move the password config set username empty ''.
     """
     mock_config = {'feed': 'http://:[email protected]'}
     expected_clean_config = {'feed': 'http://realfeed.com', 'basic_auth_username': '',
                              'basic_auth_password': '******'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 15
0
 def test_feed_with_basic_auth_username_password(self):
     """
     Ensure that username and password are removed from the feed and put into the config.
     """
     mock_config = {'feed': 'http://*****:*****@realfeed.com'}
     expected_clean_config = {'feed': 'http://realfeed.com', 'basic_auth_username': '******',
                              'basic_auth_password': '******'}
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)
Esempio n. 16
0
 def test_feed_with_basic_auth_password(self):
     """
     If password but not username is in the feed, move the password config set username empty ''.
     """
     mock_config = {"feed": "http://:[email protected]"}
     expected_clean_config = {
         "feed": "http://realfeed.com",
         "basic_auth_username": "",
         "basic_auth_password": "******",
     }
     result = importer.clean_config_dict(mock_config)
     self.assertDictEqual(expected_clean_config, result)