def test_import_config(self): # arrange expected_gitlab_key = 'blahblahblah' expected_gitlab_url = 'https://gitlab.test.com' expected_default = 'local' # act config = fen_cli.import_config(self.python_gitlab_filename) gitlab_url = config.get(section='local', option='url') gitlab_key = config.get(section='local', option='private_token') gitlab_default = config.get(section='global', option='default') # assert self.assertEqual(expected_gitlab_key, gitlab_key, "Expected {}, but got {}".format(expected_gitlab_key, gitlab_key)) self.assertEqual(expected_gitlab_url, gitlab_url, "Expected {}, but got {}".format(expected_gitlab_url, gitlab_url)) self.assertEqual(expected_default, gitlab_default, "Expected {}, but got {}".format(expected_default, gitlab_default))
def test_failed_to_read_config(self): with self.assertRaises(ConfigParser.MissingSectionHeaderError): config = fen_cli.import_config(self.bad_gitlab_filename)
def test_failed_import_config(self): self.unknown_file_path = 'yadayada' with self.assertRaises(IOError): config = fen_cli.import_config(self.unknown_file_path)