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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)