Example #1
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
Example #2
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
Example #3
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"]
Example #4
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"
Example #5
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"
Example #6
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
Example #7
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()
Example #8
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"]