Commit 49b0692c authored by FH's avatar FH

use dev pacman-mirrors.conf

parent 5589c5a0
......@@ -78,8 +78,8 @@ class PacmanMirrors:
self.default_mirror_list = "/etc/pacman.d/mirrorlist"
self.custom_mirror_dir = "/var/lib/pacman-mirrors"
self.custom_mirror_file = "/var/lib/pacman-mirrors/Custom"
# Get config from file
self.config = self.config_init()
# Define config
self.config = {}
def append_to_server_list(self, mirror, last_sync):
"""
......@@ -765,6 +765,8 @@ class PacmanMirrors:
def run(self):
"""Run"""
# Get config from file
self.config = self.config_init()
self.command_line_parse()
self.load_server_lists()
if self.interactive:
......@@ -774,5 +776,5 @@ class PacmanMirrors:
if __name__ == "__main__":
pm = PacmanMirrors()
pm.run()
pmapp = PacmanMirrors()
pmapp.run()
......@@ -29,6 +29,7 @@ class TestPacmanMirrors(unittest.TestCase):
"-d", "data/mirrors"]):
app = pacman_mirrors.PacmanMirrors()
app.config_file = "conf/pacman-mirrors.conf"
app.config = app.config_init()
app.command_line_parse()
app.load_server_lists()
......@@ -44,6 +45,7 @@ class TestPacmanMirrors(unittest.TestCase):
"-d", "data/mirrors"]):
app = pacman_mirrors.PacmanMirrors()
app.config_file = "conf/pacman-mirrors.conf"
app.config = app.config_init()
app.command_line_parse()
app.load_server_lists()
assert app.config["only_country"] == ["Germany"]
......@@ -62,6 +64,7 @@ class TestPacmanMirrors(unittest.TestCase):
"-d", "data/mirrors"]):
app = pacman_mirrors.PacmanMirrors()
app.config_file = "conf/pacman-mirrors.conf"
app.config = app.config_init()
app.command_line_parse()
app.load_server_lists()
assert app.config["only_country"] == ["France"]
......@@ -80,6 +83,7 @@ class TestPacmanMirrors(unittest.TestCase):
"-d", "data/mirrors"]):
app = pacman_mirrors.PacmanMirrors()
app.config_file = "conf/pacman-mirrors.conf"
app.config = app.config_init()
app.config["only_country"] = []
app.command_line_parse()
app.load_server_lists()
......@@ -89,7 +93,6 @@ class TestPacmanMirrors(unittest.TestCase):
def test_resp_time_calc(self, mock_calc):
"""Calculate mirror response time"""
app = pacman_mirrors.PacmanMirrors()
app.config_file = "conf/pacman-mirrors.conf"
mock_calc.return_value = "0.067"
assert app.get_mirror_response_time(
"1486371026.6549892", "1486371026.7216527") == "0.067"
......@@ -104,7 +107,6 @@ class TestPacmanMirrors(unittest.TestCase):
def test_last_sync_calc(self, mock_calc):
"""Calculate mirror last_sync offset"""
app = pacman_mirrors.PacmanMirrors()
app.config_file = "conf/pacman-mirrors.conf"
mock_calc.return_value = "2189:29"
assert app.get_mirror_branch_last_sync(
"2017-02-06 11:39:14.610344", "2016-11-07 06:09:51") == "2189:29"
......@@ -120,7 +122,6 @@ class TestPacmanMirrors(unittest.TestCase):
"""Extract mirror url from input"""
mock_url.return_value = "http://mirror.domain.tld"
app = pacman_mirrors.PacmanMirrors()
app.config_file = "conf/pacman-mirrors.conf"
mock_data = "Server = http://mirror.domain.tld"
assert app.get_mirror_url(mock_data) == "http://mirror.domain.tld"
......@@ -129,7 +130,6 @@ class TestPacmanMirrors(unittest.TestCase):
"""Extract mirror country from input"""
mock_country.return_value = "France"
app = pacman_mirrors.PacmanMirrors()
app.config_file = "conf/pacman-mirrors.conf"
mock_data = "## Country : France"
assert app.get_mirror_country(mock_data) == "France"
mock_data = "## Location : France"
......@@ -142,7 +142,6 @@ class TestPacmanMirrors(unittest.TestCase):
"""Extract timestamp from input"""
mock_timestamp.return_value = "2017-02-06T07:18:43Z"
app = pacman_mirrors.PacmanMirrors()
app.config_file = "conf/pacman-mirrors.conf"
mock_data = "date=2017-02-06T07:18:43Z"
assert app.get_mirror_branch_timestamp(mock_data) == "2017-02-06T07:18:43Z"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment