mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-08 05:50:47 +00:00
Tests for mirror list/show.
This commit is contained in:
+20
-11
@@ -4,17 +4,28 @@ Test library.
|
||||
|
||||
import difflib
|
||||
import inspect
|
||||
import json
|
||||
import subprocess
|
||||
import os
|
||||
import shutil
|
||||
import string
|
||||
|
||||
|
||||
class BaseTest(object):
|
||||
"""
|
||||
Base class for all tests.
|
||||
"""
|
||||
|
||||
expectedCode = 0
|
||||
configFile = {
|
||||
"rootDir": "%s/.aptly" % os.environ["HOME"],
|
||||
"downloadConcurrency": 4,
|
||||
"architectures": [],
|
||||
"dependencyFollowSuggests": False,
|
||||
"dependencyFollowRecommends": False,
|
||||
"dependencyFollowAllVariants": False
|
||||
}
|
||||
configOverride = {}
|
||||
|
||||
def test(self):
|
||||
self.prepare()
|
||||
@@ -28,10 +39,17 @@ class BaseTest(object):
|
||||
os.remove(os.path.join(os.environ["HOME"], ".aptly.conf"))
|
||||
|
||||
def prepare_default_config(self):
|
||||
cfg = self.configFile.copy()
|
||||
cfg.update(**self.configOverride)
|
||||
f = open(os.path.join(os.environ["HOME"], ".aptly.conf"), "w")
|
||||
f.write(config_file)
|
||||
f.write(json.dumps(cfg))
|
||||
f.close()
|
||||
|
||||
def prepare_fixture(self):
|
||||
if hasattr(self, "fixtureCmds"):
|
||||
for cmd in self.fixtureCmds:
|
||||
self.run_cmd(cmd)
|
||||
|
||||
def run(self):
|
||||
self.output = self.run_cmd(self.runCmd, self.expectedCode)
|
||||
|
||||
@@ -75,14 +93,5 @@ class BaseTest(object):
|
||||
def prepare(self):
|
||||
self.prepare_remove_all()
|
||||
self.prepare_default_config()
|
||||
self.prepare_fixture()
|
||||
|
||||
config_file = """
|
||||
{
|
||||
"rootDir": "%s/.aptly",
|
||||
"downloadConcurrency": 4,
|
||||
"architectures": [],
|
||||
"dependencyFollowSuggests": false,
|
||||
"dependencyFollowRecommends": false,
|
||||
"dependencyFollowAllVariants": false
|
||||
}
|
||||
""" % (os.environ["HOME"])
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release...
|
||||
|
||||
Mirror [mirror7]: http://mirror.yandex.ru/debian/ wheezy successfully added.
|
||||
You can run 'aptly mirror update mirror7' to download repository contents.
|
||||
@@ -0,0 +1,18 @@
|
||||
Name: mirror7
|
||||
Archive Root URL: http://mirror.yandex.ru/debian/
|
||||
Distribution: wheezy
|
||||
Components: main, contrib
|
||||
Architectures: i386, amd64
|
||||
Last update: never
|
||||
|
||||
Information from release file:
|
||||
Architectures: amd64 armel armhf i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc
|
||||
Codename: wheezy
|
||||
Components: main contrib non-free
|
||||
Date: Sat, 14 Dec 2013 10:51:30 UTC
|
||||
Description: Debian 7.3 Released 14 December 2013
|
||||
|
||||
Label: Debian
|
||||
Origin: Debian
|
||||
Suite: stable
|
||||
Version: 7.3
|
||||
@@ -0,0 +1,6 @@
|
||||
List of mirrors:
|
||||
* [mirror1]: http://mirror.yandex.ru/debian/ wheezy
|
||||
* [mirror2]: http://mirror.yandex.ru/debian/ squeeze
|
||||
* [mirror3]: http://mirror.yandex.ru/debian/ squeeze
|
||||
|
||||
To get more information about mirror, run `aptly mirror show <name>`.
|
||||
@@ -0,0 +1 @@
|
||||
No mirrors found, create one with `aptly mirror create ...`.
|
||||
@@ -0,0 +1,18 @@
|
||||
Name: mirror1
|
||||
Archive Root URL: http://mirror.yandex.ru/debian/
|
||||
Distribution: wheezy
|
||||
Components: main, contrib, non-free
|
||||
Architectures: amd64, armel, armhf, i386, ia64, kfreebsd-amd64, kfreebsd-i386, mips, mipsel, powerpc, s390, s390x, sparc
|
||||
Last update: never
|
||||
|
||||
Information from release file:
|
||||
Architectures: amd64 armel armhf i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc
|
||||
Codename: wheezy
|
||||
Components: main contrib non-free
|
||||
Date: Sat, 14 Dec 2013 10:51:30 UTC
|
||||
Description: Debian 7.3 Released 14 December 2013
|
||||
|
||||
Label: Debian
|
||||
Origin: Debian
|
||||
Suite: stable
|
||||
Version: 7.3
|
||||
@@ -0,0 +1 @@
|
||||
ERROR: unable to show: mirror with name mirror-xx not found
|
||||
@@ -3,3 +3,5 @@ Testing mirror management
|
||||
"""
|
||||
|
||||
from .create import *
|
||||
from .show import *
|
||||
from .list import *
|
||||
|
||||
@@ -59,3 +59,17 @@ class CreateMirror6Test(BaseTest):
|
||||
expectedCode = 1
|
||||
|
||||
runCmd = "aptly mirror create mirror6 http://mirror.yandex.ru/debian/ suslik"
|
||||
|
||||
|
||||
class CreateMirror7Test(BaseTest):
|
||||
"""
|
||||
create mirror: architectures fixed via config file
|
||||
"""
|
||||
runCmd = "aptly mirror create mirror7 http://mirror.yandex.ru/debian/ wheezy main contrib"
|
||||
configOverride = {"architectures": ["i386", "amd64"]}
|
||||
|
||||
def check(self):
|
||||
self.check_output()
|
||||
self.check_cmd_output("aptly mirror show mirror7", "mirror_show")
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class ListMirror1Test(BaseTest):
|
||||
"""
|
||||
list mirrors: regular list
|
||||
"""
|
||||
fixtureCmds = [
|
||||
"aptly mirror create mirror1 http://mirror.yandex.ru/debian/ wheezy",
|
||||
"aptly mirror create mirror2 http://mirror.yandex.ru/debian/ squeeze contrib",
|
||||
"aptly -architectures=i386 mirror create mirror3 http://mirror.yandex.ru/debian/ squeeze non-free",
|
||||
]
|
||||
runCmd = "aptly mirror list"
|
||||
|
||||
|
||||
class ListMirror2Test(BaseTest):
|
||||
"""
|
||||
list mirrors: empty list
|
||||
"""
|
||||
runCmd = "aptly mirror list"
|
||||
@@ -0,0 +1,17 @@
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class ShowMirror1Test(BaseTest):
|
||||
"""
|
||||
show mirror: regular mirror
|
||||
"""
|
||||
fixtureCmds = ["aptly mirror create mirror1 http://mirror.yandex.ru/debian/ wheezy"]
|
||||
runCmd = "aptly mirror show mirror1"
|
||||
|
||||
|
||||
class ShowMirror2Test(BaseTest):
|
||||
"""
|
||||
show mirror: missing mirror
|
||||
"""
|
||||
runCmd = "aptly mirror show mirror-xx"
|
||||
expectedCode = 1
|
||||
Reference in New Issue
Block a user