Esempio n. 1
0
 def test_set_config_options(self):
     """
     Test writing to config file, make sure writen values are written correctly
     :return:
     """
     # set up config
     config.set_config_file(
         os.path.join(path_to_module, "example_config.conf"))
     config.setup()
     # Make sure id is initially set to what we expect
     self.assertEqual(config.read_config_option('client_id'), 'uploader')
     # Set and test to a new id
     config.set_config_options(client_id="new_id")
     self.assertEqual(config.read_config_option('client_id'), "new_id")
Esempio n. 2
0
def _config_uploader(args):
    """
    Sets up config settings for command line uploading
    :param args:
    :return:
    """
    # If a config file is passed in, set it before starting upload
    if args.config:
        config.set_config_file(args.config)
        # config.user_config_file = args.config
    # Init config
    config.setup()
    # Override with any passed in options
    _set_config_override(args)
Esempio n. 3
0
 def test_dont_create_new_file_if_override_file_exists(
         self, mock_path_exists, mock_create_new_config_file,
         mock_load_config_from_file, mock_init_config_parser):
     # Set the config file to False so that the function will check if a default file is set
     config.set_config_file(False)
     # When it checks for config files, return True on check for override so it wont attempt to create a new file
     mock_path_exists.side_effect = [False, True]
     # If a new file is created, no exit will happen
     config.setup()
     # First init happens
     mock_init_config_parser.assert_called_with()
     # make sure no attempt to create a file happens
     mock_create_new_config_file.assert_not_called()
     # make sure it tries to load from file
     mock_load_config_from_file.assert_called_with()
Esempio n. 4
0
    def test_create_new_file_if_none_exist(self, mock_path_exists,
                                           mock_create_new_config_file,
                                           mock_load_config_from_file):

        # Set the config file to False so that the function will check if a default file is set
        config.set_config_file(False)
        # When it checks for a default path and override path,
        # return False for bothso it will attempt to create a new file
        mock_path_exists.side_effect = [False, False]
        # try setting up config to trigger creating a new file
        config.setup()
        # make sure the attempt to create a file happens
        mock_create_new_config_file.assert_called_with()
        # It will attempt to use the file that was just created
        mock_load_config_from_file.assert_called_with()
Esempio n. 5
0
    def test_basic_setup_all_functions_called(self, mock_path_exists,
                                              mock_create_new_config_file,
                                              mock_load_config_from_file,
                                              mock_init_config_parser):

        # Set the config file to True so that it thinks there is a config file
        config.set_config_file(True)
        # start up config setup
        config.setup()
        # First init happens
        mock_init_config_parser.assert_called_with()
        # make sure no attempt to create a file happens
        mock_create_new_config_file.assert_not_called()
        # make sure it tries to load from file
        mock_load_config_from_file.assert_called_with()
Esempio n. 6
0
 def test_read_config_option(self):
     """
     Test writing to config file, make sure writen values are written correctly
     :return:
     """
     # set up config
     config.set_config_file(
         os.path.join(path_to_module, "example_config.conf"))
     config.setup()
     # Test that all the parameters loaded from file are correct
     self.assertEqual(config.read_config_option('client_id'), 'uploader')
     self.assertEqual(config.read_config_option('client_secret'), 'secret')
     self.assertEqual(config.read_config_option('username'), 'admin')
     self.assertEqual(config.read_config_option('password'), 'password1')
     self.assertEqual(config.read_config_option('base_url'),
                      'http://localhost:8080/irida-latest/api/')
     self.assertEqual(config.read_config_option('parser'), 'miseq')
 def setUp(self):
     print("\nStarting " + self.__module__ + ": " + self._testMethodName)
     # Set the config file to our test config, so that when the upload is run it grabs out config file correctly
     config.set_config_file(path.join(path_to_module, "test_config.conf"))
     config.setup()