Beispiel #1
0
 def test_default_mirrordir(self, mock_build_config, mock_os_getuid):
     """TEST: config[mirror_dir] = tests/mock/var/"""
     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.setup_config()
         assert app.config["work_dir"] == "tests/mock/var/"
Beispiel #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"
Beispiel #3
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
Beispiel #4
0
 def test_default_mirrorfile(self, mock_build_config, mock_os_getuid):
     """TEST: config[mirror_file] = tests/mock/usr/mirrors.json"""
     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.setup_config()
         assert app.config["mirror_file"] == "tests/mock/usr/mirrors.json"
Beispiel #5
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"
Beispiel #6
0
 def test_default_branch(self, mock_build_config, mock_os_getuid):
     """TEST: config[branch] = stable"""
     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.setup_config()
         assert app.config["branch"] == "stable"
Beispiel #7
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"] == []
Beispiel #8
0
 def test_arg_quiet(self, mock_build_config, mock_os_getuid):
     """TEST: CLI quiet is True from ARG '-q'"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "-q"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.setup_config()
         cliFn.parse_command_line(app, True)
         assert app.quiet is True
Beispiel #9
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"] = mock.CONFIG_FILE
         app.config = configFn.setup_config()
         cliFn.parse_command_line(app, True)
         assert app.max_wait_time == 5
 def test_default_mirrorfile(self, mock_build_config, mock_os_getuid):
     """TEST: config[mirror_file] = tests/mock/usr/mirrors.json"""
     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.setup_config()
         assert app.config["mirror_file"] == "tests/mock/usr/mirrors.json"
 def test_default_mirrordir(self, mock_build_config, mock_os_getuid):
     """TEST: config[mirror_dir] = tests/mock/var/"""
     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.setup_config()
         assert app.config["work_dir"] == "tests/mock/var/"
 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.setup_config()
         assert app.config["no_update"] is False
 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.setup_config()
         assert app.config["country_pool"] == []
 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.setup_config()
         assert app.config["method"] == "rank"
Beispiel #15
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.setup_config()
         cliFn.parse_command_line(app, True)
         assert app.config["method"] == "random"
Beispiel #16
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.setup_config()
         cliFn.parse_command_line(app, True)
         assert app.config["country_pool"] == ["France", "Germany"]
 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.setup_config()
         cliFn.parse_command_line(app, True)
         assert app.config["method"] == "random"
 def test_arg_quiet(self, mock_build_config, mock_os_getuid):
     """TEST: CLI quiet is True from ARG '-q'"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv",
                              ["pacman-mirrors",
                               "-q"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.setup_config()
         cliFn.parse_command_line(app, True)
         assert app.quiet is True
 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.setup_config()
         cliFn.parse_command_line(app, True)
         assert app.config["country_pool"] == ["France", "Germany"]
Beispiel #20
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.setup_config()
         fileFn.create_dir(test_conf["work_dir"])
         cliFn.parse_command_line(app, True)
         httpFn.update_mirror_pool(app.config)
         defaultFn.load_default_mirror_pool(app)
         common.build_mirror_list(app)
Beispiel #21
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()
 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.setup_config()
         fileFn.create_dir(test_conf["work_dir"])
         cliFn.parse_command_line(app, True)
         httpFn.update_mirror_pool(app.config)
         defaultFn.load_default_mirror_pool(app)
         common.build_mirror_list(app)
 def test_initial_quiet(self, mock_os_getuid):
     """TEST: self.quiet is False"""
     mock_os_getuid.return_value = 0
     with unittest.mock.patch("sys.argv",
                              ["pacman-mirrors", "-f1"]):
         app = PacmanMirrors()
         assert app.quiet is False
 def test_initial_max_wait_time(self, mock_os_getuid):
     """TEST: self.max_wait_time = 2"""
     mock_os_getuid.return_value = 0
     with unittest.mock.patch("sys.argv",
                              ["pacman-mirrors", "-f1"]):
         app = PacmanMirrors()
         assert app.max_wait_time == 2
 def test_initial_network(self, mock_os_getuid):
     """TEST: self.network is True"""
     mock_os_getuid.return_value = 0
     with unittest.mock.patch("sys.argv",
                              ["pacman-mirrors", "-f1"]):
         app = PacmanMirrors()
         assert app.network is True
 def test_initial_selected_countries(self, mock_os_getuid):
     """TEST: self.selected_countries = []"""
     mock_os_getuid.return_value = 0
     with unittest.mock.patch("sys.argv",
                              ["pacman-mirrors", "-f1"]):
         app = PacmanMirrors()
         assert app.selected_countries == []
Beispiel #27
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.setup_config()
         cliFn.parse_command_line(app, True)
         defaultFn.load_default_mirror_pool(app)
         app.selected_countries = httpFn.get_geoip_country()
         assert app.selected_countries == ["Denmark"]
Beispiel #28
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.setup_config()
         cliFn.parse_command_line(app, True)
         defaultFn.load_default_mirror_pool(app)
         app.selected_countries = httpFn.get_ip_country()
         assert app.selected_countries == ["Denmark"]
 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
Beispiel #30
0
 def test_arg_fasttrack(self, mock_build_config, mock_os_getuid):
     """TEST: CLI fasttrack is 5 from ARG '-f 5'"""
     mock_os_getuid.return_value = 0
     mock_build_config.return_value = test_conf
     with unittest.mock.patch("sys.argv", ["pacman-mirrors", "-f5"]):
         app = PacmanMirrors()
         app.config["config_file"] = conf.CONFIG_FILE
         app.config = configFn.build_config()
         app.command_line_parse()
         assert app.fasttrack == 5
Beispiel #31
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
Beispiel #32
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"