Esempio n. 1
0
 def test_default_noupdate(self, mock_build_config, mock_os_getuid):
     """TEST: config[no_update] = False"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "-f1"]):
         app = PacmanMirrors()
         app.config = configFn.build_config()
         assert app.config["no_update"] is False
Esempio n. 2
0
 def test_default_mirrorlist(self, mock_build_config, mock_os_getuid):
     """TEST: config[mirror_list] = tests/mock/etc/mirrorlist"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "-f1"]):
         app = PacmanMirrors()
         app.config = configFn.build_config()
         assert app.config["mirror_list"] == "tests/mock/etc/mirrorlist"
Esempio n. 3
0
 def test_default_method(self, mock_build_config, mock_os_getuid):
     """TEST: config[method] = rank"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "-f1"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.build_config()
         assert app.config["method"] == "rank"
Esempio n. 4
0
 def test_default_onlycountry(self, mock_build_config, mock_os_getuid):
     """TEST: config[only_country] = []"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "-f1"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.build_config()
         assert app.config["country_pool"] == []
Esempio n. 5
0
 def test_arg_geoip(self, mock_build_config, mock_os_getuid):
     """TEST: CLI geoip is True from ARG '--geoip'"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "--geoip"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.build_config()
         app.command_line_parse()
         assert app.geoip is True
Esempio n. 6
0
 def test_arg_max_wait_time(self, mock_build_config, mock_os_getuid):
     """TEST: CLI max_wait_time is 5 from ARG '-t 5'"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "-t5"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.build_config()
         app.command_line_parse()
         assert app.max_wait_time == 5
Esempio n. 7
0
 def test_arg_onlycountry(self, mock_build_config, mock_os_getuid):
     """TEST: CLI config[only_country] from ARG '-c France,Germany'"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv",
                              ["pacman-mirrors", "-c", "France,Germany"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.build_config()
         app.command_line_parse()
         assert app.config["country_pool"] == ["France", "Germany"]
Esempio n. 8
0
 def test_arg_method(self, mock_build_config, mock_os_getuid):
     """TEST: CLI config[method] from ARG '-m random'"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv",
                              ["pacman-mirrors", "-m", "random"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.build_config()
         app.command_line_parse()
         assert app.config["method"] == "random"
Esempio n. 9
0
 def test_arg_branch_testing(self, mock_build_config, mock_os_getuid):
     """TEST: CLI config[branch] from ARG '-b testing'"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv",
                              ["pacman-mirrors", "-b", "testing"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.build_config()
         app.command_line_parse()
         assert app.config["branch"] == "testing"
Esempio n. 10
0
 def test_geoip_not_available(self, mock_build_config,
                              mock_get_geoip_country, mock_os_getuid):
     """TEST: geoip country IS NOT available"""
     mock_os_getuid.return_value = 0
     mock_get_geoip_country.return_value = "Antarctica"
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "--geoip"]):
         app = PacmanMirrors()
         app.config = configFn.build_config()
         app.command_line_parse()
         app.load_all_mirrors()
         assert app.selected_countries == app.mirrors.country_pool
Esempio n. 11
0
 def test_full_run_rank(self, mock_build_config, mock_os_getuid):
     """TEST: pacman-mirrors -c all"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "-c", "all"]):
         app = PacmanMirrors()
         app.config = configFn.build_config()
         fileFn.create_dir(test_conf["work_dir"])
         app.command_line_parse()
         httpFn.update_mirrors(app.config)
         app.load_all_mirrors()
         app.build_common_mirror_list()
Esempio n. 12
0
 def test_geoip_available(self, mock_build_config, mock_get_geoip_country,
                          mock_os_getuid):
     """TEST: geoip country IS avaiable"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     mock_get_geoip_country.return_value = ["Denmark"]
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "--geoip"]):
         app = PacmanMirrors()
         app.config = configFn.build_config()
         app.command_line_parse()
         app.load_all_mirrors()
         app.selected_countries = httpFn.get_geoip_country()
         assert app.selected_countries == ["Denmark"]
Esempio n. 13
0
 def run(self):
     """
     Run
     # Build internal config dictionary
     # Returns the config dictionary and true/false on custom
     # Parse commandline
     # i686 check - change branch to x32-$branch
     # Check network
     # Check if mirrorlist is not to be touched - normal exit
     # Handle missing network
     """
     (self.config, self.custom) = configFn.build_config()
     fileFn.create_dir(self.config["work_dir"])
     self.command_line_parse()
     self.i686_check(write=True)
     self.network = httpFn.inet_conn_check()
     if self.network:
         httpFn.update_mirrors(self.config, quiet=self.quiet)
     if self.no_mirrorlist:
         sys.exit(0)
     if not self.network:
         if not self.quiet:
             pacman_mirrors.functions.util.internet_message()
         self.config["method"] = "random"
         self.fasttrack = False
     """
     # Load all mirrors
     """
     self.load_all_mirrors()
     """
     # Decide which type of mirrorlist to create
     * Fasttrack
     * Interactive
     * Default
     """
     if self.fasttrack:
         self.build_fasttrack_mirror_list(self.fasttrack)
     elif self.interactive:
         self.build_interactive_mirror_list()
     else:
         self.build_common_mirror_list()