Add system's requirements.txt, enforce flake8 linter

Fix style issues in functional tests.
This commit is contained in:
Andrey Smirnov
2017-04-27 18:58:15 +03:00
parent 7a7b981d4f
commit c798db8056
44 changed files with 334 additions and 260 deletions

2
.gitignore vendored
View File

@@ -34,3 +34,5 @@ man/aptly.1.html
man/aptly.1.ronn man/aptly.1.ronn
.goxc.local.json .goxc.local.json
system/env/

View File

@@ -24,7 +24,6 @@ before_install:
- . env/bin/activate - . env/bin/activate
- pip install six packaging appdirs - pip install six packaging appdirs
- pip install -U pip setuptools - pip install -U pip setuptools
- pip install boto requests requests-unixsocket python-swiftclient
- mkdir -p $GOPATH/src/github.com/smira - mkdir -p $GOPATH/src/github.com/smira
- ln -s $TRAVIS_BUILD_DIR $GOPATH/src/github.com/smira || true - ln -s $TRAVIS_BUILD_DIR $GOPATH/src/github.com/smira || true
- cd $GOPATH/src/github.com/smira/aptly - cd $GOPATH/src/github.com/smira/aptly

View File

@@ -35,16 +35,22 @@ coverage: coverage.out
go tool cover -html=coverage.out go tool cover -html=coverage.out
rm -f coverage.out rm -f coverage.out
check: check: system/env
gometalinter --vendor --vendored-linters --config=linter.json ./... gometalinter --vendor --vendored-linters --config=linter.json ./...
. system/env/bin/activate && flake8 --max-line-length=200 --exclude=env/ system/
install: install:
go install -v -ldflags "-X main.Version=$(VERSION)" go install -v -ldflags "-X main.Version=$(VERSION)"
system-test: install system/env: system/requirements.txt
rm -rf system/env
virtualenv system/env
system/env/bin/pip install -r system/requirements.txt
system-test: install system/env
if [ ! -e ~/aptly-fixture-db ]; then git clone https://github.com/aptly-dev/aptly-fixture-db.git ~/aptly-fixture-db/; fi if [ ! -e ~/aptly-fixture-db ]; then git clone https://github.com/aptly-dev/aptly-fixture-db.git ~/aptly-fixture-db/; fi
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
APTLY_VERSION=$(VERSION) PATH=$(BINPATH)/:$(PATH) $(PYTHON) system/run.py --long $(TESTS) . system/env/bin/activate && APTLY_VERSION=$(VERSION) PATH=$(BINPATH)/:$(PATH) $(PYTHON) system/run.py --long $(TESTS)
travis: $(TRAVIS_TARGET) check system-test travis: $(TRAVIS_TARGET) check system-test

View File

@@ -42,7 +42,7 @@ class APITest(BaseTest):
def post(self, uri, *args, **kwargs): def post(self, uri, *args, **kwargs):
if "json" in kwargs: if "json" in kwargs:
kwargs["data"] = json.dumps(kwargs.pop("json")) kwargs["data"] = json.dumps(kwargs.pop("json"))
if not "headers" in kwargs: if "headers" not in kwargs:
kwargs["headers"] = {} kwargs["headers"] = {}
kwargs["headers"]["Content-Type"] = "application/json" kwargs["headers"]["Content-Type"] = "application/json"
return requests.post("http://%s%s" % (self.base_url, uri), *args, **kwargs) return requests.post("http://%s%s" % (self.base_url, uri), *args, **kwargs)
@@ -50,7 +50,7 @@ class APITest(BaseTest):
def put(self, uri, *args, **kwargs): def put(self, uri, *args, **kwargs):
if "json" in kwargs: if "json" in kwargs:
kwargs["data"] = json.dumps(kwargs.pop("json")) kwargs["data"] = json.dumps(kwargs.pop("json"))
if not "headers" in kwargs: if "headers" not in kwargs:
kwargs["headers"] = {} kwargs["headers"] = {}
kwargs["headers"]["Content-Type"] = "application/json" kwargs["headers"]["Content-Type"] = "application/json"
return requests.put("http://%s%s" % (self.base_url, uri), *args, **kwargs) return requests.put("http://%s%s" % (self.base_url, uri), *args, **kwargs)
@@ -58,7 +58,7 @@ class APITest(BaseTest):
def delete(self, uri, *args, **kwargs): def delete(self, uri, *args, **kwargs):
if "json" in kwargs: if "json" in kwargs:
kwargs["data"] = json.dumps(kwargs.pop("json")) kwargs["data"] = json.dumps(kwargs.pop("json"))
if not "headers" in kwargs: if "headers" not in kwargs:
kwargs["headers"] = {} kwargs["headers"] = {}
kwargs["headers"]["Content-Type"] = "application/json" kwargs["headers"]["Content-Type"] = "application/json"
return requests.delete("http://%s%s" % (self.base_url, uri), *args, **kwargs) return requests.delete("http://%s%s" % (self.base_url, uri), *args, **kwargs)

View File

@@ -1,13 +1,14 @@
import os import os
from lib import BaseTest from lib import BaseTest
class FileSystemEndpointTest(BaseTest): class FileSystemEndpointTest(BaseTest):
""" """
BaseTest + support for filesystem endpoints BaseTest + support for filesystem endpoints
""" """
def prepare(self): def prepare(self):
self.configOverride = { "FileSystemPublishEndpoints": { self.configOverride = {"FileSystemPublishEndpoints": {
"symlink": { "symlink": {
"rootDir": os.path.join(os.environ["HOME"], ".aptly", "public_symlink"), "rootDir": os.path.join(os.environ["HOME"], ".aptly", "public_symlink"),
"linkMethod": "symlink" "linkMethod": "symlink"
@@ -29,7 +30,6 @@ class FileSystemEndpointTest(BaseTest):
}} }}
super(FileSystemEndpointTest, self).prepare() super(FileSystemEndpointTest, self).prepare()
def check_is_regular(self, path): def check_is_regular(self, path):
if not os.path.isfile(os.path.join(os.environ["HOME"], ".aptly", path)): if not os.path.isfile(os.path.join(os.environ["HOME"], ".aptly", path)):
raise Exception("path %s is not a regular file" % (path, )) raise Exception("path %s is not a regular file" % (path, ))
@@ -44,5 +44,5 @@ class FileSystemEndpointTest(BaseTest):
def check_is_copy(self, path): def check_is_copy(self, path):
fullpath = os.path.join(os.environ["HOME"], ".aptly", path) fullpath = os.path.join(os.environ["HOME"], ".aptly", path)
if not ( os.path.isfile(fullpath) and not self.check_is_hardlink(path) ): if not (os.path.isfile(fullpath) and not self.check_is_hardlink(path)):
raise Exception("path %s is not a copy" % (path, )) raise Exception("path %s is not a copy" % (path, ))

View File

@@ -13,7 +13,6 @@ import shutil
import string import string
import threading import threading
import urllib import urllib
#import time
import pprint import pprint
import SocketServer import SocketServer
import SimpleHTTPServer import SimpleHTTPServer
@@ -118,19 +117,15 @@ class BaseTest(object):
def prepare_fixture(self): def prepare_fixture(self):
if self.fixturePool: if self.fixturePool:
#start = time.time()
os.makedirs(os.path.join(os.environ["HOME"], ".aptly"), 0755) os.makedirs(os.path.join(os.environ["HOME"], ".aptly"), 0755)
os.symlink(self.fixturePoolDir, os.path.join(os.environ["HOME"], ".aptly", "pool")) os.symlink(self.fixturePoolDir, os.path.join(os.environ["HOME"], ".aptly", "pool"))
#print "FIXTURE POOL: %.2f" % (time.time()-start)
if self.fixturePoolCopy: if self.fixturePoolCopy:
os.makedirs(os.path.join(os.environ["HOME"], ".aptly"), 0755) os.makedirs(os.path.join(os.environ["HOME"], ".aptly"), 0755)
shutil.copytree(self.fixturePoolDir, os.path.join(os.environ["HOME"], ".aptly", "pool"), ignore=shutil.ignore_patterns(".git")) shutil.copytree(self.fixturePoolDir, os.path.join(os.environ["HOME"], ".aptly", "pool"), ignore=shutil.ignore_patterns(".git"))
if self.fixtureDB: if self.fixtureDB:
#start = time.time()
shutil.copytree(self.fixtureDBDir, os.path.join(os.environ["HOME"], ".aptly", "db")) shutil.copytree(self.fixtureDBDir, os.path.join(os.environ["HOME"], ".aptly", "db"))
#print "FIXTURE DB: %.2f" % (time.time()-start)
if self.fixtureWebServer: if self.fixtureWebServer:
self.webServerUrl = self.start_webserver(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.webServerUrl = self.start_webserver(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)),
@@ -172,10 +167,8 @@ class BaseTest(object):
def run_cmd(self, command, expected_code=0): def run_cmd(self, command, expected_code=0):
try: try:
#start = time.time()
proc = self._start_process(command, stdout=subprocess.PIPE) proc = self._start_process(command, stdout=subprocess.PIPE)
output, _ = proc.communicate() output, _ = proc.communicate()
#print "CMD %s: %.2f" % (" ".join(command), time.time()-start)
if proc.returncode != expected_code: if proc.returncode != expected_code:
raise Exception("exit code %d != %d (output: %s)" % (proc.returncode, expected_code, output)) raise Exception("exit code %d != %d (output: %s)" % (proc.returncode, expected_code, output))
return output return output
@@ -279,7 +272,7 @@ class BaseTest(object):
raise Exception("%s is not greater to %s" % (a, b)) raise Exception("%s is not greater to %s" % (a, b))
def check_in(self, item, l): def check_in(self, item, l):
if not item in l: if item not in l:
raise Exception("item %r not in %r", item, l) raise Exception("item %r not in %r", item, l)
def check_subset(self, a, b): def check_subset(self, a, b):

5
system/requirements.txt Normal file
View File

@@ -0,0 +1,5 @@
boto
requests
requests-unixsocket
python-swiftclient
flake8

View File

@@ -22,6 +22,16 @@ except ImportError:
return s return s
def walk_modules(package):
yield importlib.import_module(package)
for name in glob.glob(package + "/*.py"):
name = os.path.splitext(os.path.basename(name))[0]
if name == "__init__":
continue
yield importlib.import_module(package + "." + name)
def run(include_long_tests=False, capture_results=False, tests=None, filters=None): def run(include_long_tests=False, capture_results=False, tests=None, filters=None):
""" """
Run system test. Run system test.
@@ -33,54 +43,52 @@ def run(include_long_tests=False, capture_results=False, tests=None, filters=Non
lastBase = None lastBase = None
for test in tests: for test in tests:
for testModule in walk_modules(test):
for name in dir(testModule):
o = getattr(testModule, name)
testModule = importlib.import_module(test) if not (inspect.isclass(o) and issubclass(o, BaseTest) and o is not BaseTest and
o is not SwiftTest and o is not S3Test and o is not APITest and o is not FileSystemEndpointTest):
for name in dir(testModule):
o = getattr(testModule, name)
if not (inspect.isclass(o) and issubclass(o, BaseTest) and o is not BaseTest and
o is not SwiftTest and o is not S3Test and o is not APITest and o is not FileSystemEndpointTest):
continue
newBase = o.__bases__[0]
if lastBase is not None and lastBase is not newBase:
lastBase.shutdown_class()
lastBase = newBase
if filters:
matches = False
for filt in filters:
if fnmatch.fnmatch(o.__name__, filt):
matches = True
break
if not matches:
continue continue
t = o() newBase = o.__bases__[0]
if t.longTest and not include_long_tests or not t.fixture_available(): if lastBase is not None and lastBase is not newBase:
numSkipped += 1 lastBase.shutdown_class()
continue
numTests += 1 lastBase = newBase
sys.stdout.write("%s:%s... " % (test, o.__name__)) if filters:
matches = False
try: for filt in filters:
t.captureResults = capture_results if fnmatch.fnmatch(o.__name__, filt):
t.test() matches = True
except BaseException: break
numFailed += 1
typ, val, tb = sys.exc_info()
fails.append((test, t, typ, val, tb, testModule))
sys.stdout.write(colored("FAIL\n", color="red"))
else:
sys.stdout.write(colored("OK\n", color="green"))
t.shutdown() if not matches:
continue
t = o()
if t.longTest and not include_long_tests or not t.fixture_available():
numSkipped += 1
continue
numTests += 1
sys.stdout.write("%s:%s... " % (test, o.__name__))
try:
t.captureResults = capture_results
t.test()
except BaseException:
numFailed += 1
typ, val, tb = sys.exc_info()
fails.append((test, t, typ, val, tb, testModule))
sys.stdout.write(colored("FAIL\n", color="red"))
else:
sys.stdout.write(colored("OK\n", color="green"))
t.shutdown()
if lastBase is not None: if lastBase is not None:
lastBase.shutdown_class() lastBase.shutdown_class()
@@ -91,13 +99,13 @@ def run(include_long_tests=False, capture_results=False, tests=None, filters=Non
print "\nFAILURES (%d):" % (len(fails), ) print "\nFAILURES (%d):" % (len(fails), )
for (test, t, typ, val, tb, testModule) in fails: for (test, t, typ, val, tb, testModule) in fails:
print "%s:%s %s" % (test, t.__class__.__name__, testModule.__doc__.strip() + ": " + t.__doc__.strip()) print "%s:%s %s" % (test, t.__class__.__name__, getattr(testModule, "__doc__", "").strip() + ": " + t.__doc__.strip())
#print "ERROR: %s" % (val, )
traceback.print_exception(typ, val, tb) traceback.print_exception(typ, val, tb)
print "=" * 60 print "=" * 60
sys.exit(1) sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
if 'APTLY_VERSION' not in os.environ: if 'APTLY_VERSION' not in os.environ:
try: try:

View File

@@ -45,7 +45,8 @@ class ConfigInFileTest(BaseTest):
"-config=%s" % (os.path.join(os.path.dirname(inspect.getsourcefile(BadConfigTest)), "aptly.conf"), )] "-config=%s" % (os.path.join(os.path.dirname(inspect.getsourcefile(BadConfigTest)), "aptly.conf"), )]
prepare = BaseTest.prepare_remove_all prepare = BaseTest.prepare_remove_all
outputMatchPrepare = lambda _, s: re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE) def outputMatchPrepare(_, s):
return re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE)
class ConfigInMissingFileTest(BaseTest): class ConfigInMissingFileTest(BaseTest):

View File

@@ -13,7 +13,8 @@ class MainTest(BaseTest):
expectedCode = 2 expectedCode = 2
runCmd = "aptly" runCmd = "aptly"
outputMatchPrepare = lambda _, s: re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE) def outputMatchPrepare(_, s):
return re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE)
class MirrorTest(BaseTest): class MirrorTest(BaseTest):
@@ -38,7 +39,8 @@ class MainHelpTest(BaseTest):
""" """
runCmd = "aptly help" runCmd = "aptly help"
outputMatchPrepare = lambda _, s: re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE) def outputMatchPrepare(_, s):
return re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE)
class MirrorHelpTest(BaseTest): class MirrorHelpTest(BaseTest):

View File

@@ -1,12 +1,3 @@
""" """
Testing mirror management Testing mirror management
""" """
from .create import *
from .show import *
from .list import *
from .update import *
from .drop import *
from .rename import *
from .edit import *
from .search import *

View File

@@ -92,7 +92,9 @@ class CreateMirror9Test(BaseTest):
""" """
runCmd = "aptly mirror create --keyring=aptlytest.gpg mirror9 http://mirror.yandex.ru/debian/ wheezy-backports" runCmd = "aptly mirror create --keyring=aptlytest.gpg mirror9 http://mirror.yandex.ru/debian/ wheezy-backports"
fixtureGpg = True fixtureGpg = True
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using|Warning: using insecure memory!\n', '', s)
def outputMatchPrepare(_, s):
return re.sub(r'Signature made .* using|Warning: using insecure memory!\n', '', s)
def check(self): def check(self):
def removeDates(s): def removeDates(s):
@@ -109,9 +111,11 @@ class CreateMirror10Test(BaseTest):
runCmd = "aptly mirror create --keyring=aptlytest.gpg mirror10 http://mirror.yandex.ru/debian-backports/ squeeze-backports" runCmd = "aptly mirror create --keyring=aptlytest.gpg mirror10 http://mirror.yandex.ru/debian-backports/ squeeze-backports"
fixtureGpg = False fixtureGpg = False
gold_processor = BaseTest.expand_environ gold_processor = BaseTest.expand_environ
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using|gpgv: keyblock resource .*$|gpgv: Can\'t check signature: .*$', '', s, flags=re.MULTILINE)
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(_, s):
return re.sub(r'Signature made .* using|gpgv: keyblock resource .*$|gpgv: Can\'t check signature: .*$', '', s, flags=re.MULTILINE)
class CreateMirror11Test(BaseTest): class CreateMirror11Test(BaseTest):
""" """
@@ -119,7 +123,9 @@ class CreateMirror11Test(BaseTest):
""" """
runCmd = "aptly mirror create --keyring=aptlytest.gpg mirror11 http://mirror.yandex.ru/debian/ wheezy" runCmd = "aptly mirror create --keyring=aptlytest.gpg mirror11 http://mirror.yandex.ru/debian/ wheezy"
fixtureGpg = True fixtureGpg = True
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s)
def outputMatchPrepare(_, s):
return re.sub(r'Signature made .* using', '', s)
def check(self): def check(self):
self.check_output() self.check_output()
@@ -133,9 +139,11 @@ class CreateMirror12Test(BaseTest):
runCmd = "aptly mirror create --keyring=aptlytest.gpg mirror12 http://mirror.yandex.ru/debian/ wheezy" runCmd = "aptly mirror create --keyring=aptlytest.gpg mirror12 http://mirror.yandex.ru/debian/ wheezy"
fixtureGpg = False fixtureGpg = False
gold_processor = BaseTest.expand_environ gold_processor = BaseTest.expand_environ
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using|gpgv: keyblock resource .*$|gpgv: Can\'t check signature: .*$', '', s, flags=re.MULTILINE)
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(_, s):
return re.sub(r'Signature made .* using|gpgv: keyblock resource .*$|gpgv: Can\'t check signature: .*$', '', s, flags=re.MULTILINE)
class CreateMirror13Test(BaseTest): class CreateMirror13Test(BaseTest):
""" """
@@ -155,7 +163,9 @@ class CreateMirror14Test(BaseTest):
""" """
runCmd = "aptly mirror create -keyring=aptlytest.gpg mirror14 https://cloud.r-project.org/bin/linux/debian jessie-cran3/" runCmd = "aptly mirror create -keyring=aptlytest.gpg mirror14 https://cloud.r-project.org/bin/linux/debian jessie-cran3/"
fixtureGpg = True fixtureGpg = True
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s)
def outputMatchPrepare(_, s):
return re.sub(r'Signature made .* using', '', s)
def check(self): def check(self):
self.check_output() self.check_output()
@@ -195,8 +205,6 @@ class CreateMirror18Test(BaseTest):
create mirror: mirror with ppa URL create mirror: mirror with ppa URL
""" """
fixtureGpg = True fixtureGpg = True
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s)
configOverride = { configOverride = {
"ppaDistributorID": "ubuntu", "ppaDistributorID": "ubuntu",
"ppaCodename": "maverick", "ppaCodename": "maverick",
@@ -204,6 +212,9 @@ class CreateMirror18Test(BaseTest):
runCmd = "aptly mirror create -keyring=aptlytest.gpg mirror18 ppa:gladky-anton/gnuplot" runCmd = "aptly mirror create -keyring=aptlytest.gpg mirror18 ppa:gladky-anton/gnuplot"
def outputMatchPrepare(_, s):
return re.sub(r'Signature made .* using', '', s)
def check(self): def check(self):
self.check_output() self.check_output()
self.check_cmd_output("aptly mirror show mirror18", "mirror_show") self.check_cmd_output("aptly mirror show mirror18", "mirror_show")
@@ -214,10 +225,12 @@ class CreateMirror19Test(BaseTest):
create mirror: mirror with / in distribution create mirror: mirror with / in distribution
""" """
fixtureGpg = True fixtureGpg = True
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s)
runCmd = "aptly -architectures='i386' mirror create -keyring=aptlytest.gpg -with-sources mirror19 http://security.debian.org/ wheezy/updates main" runCmd = "aptly -architectures='i386' mirror create -keyring=aptlytest.gpg -with-sources mirror19 http://security.debian.org/ wheezy/updates main"
def outputMatchPrepare(_, s):
return re.sub(r'Signature made .* using', '', s)
def check(self): def check(self):
def removeDates(s): def removeDates(s):
return re.sub(r"(Date|Valid-Until): [,0-9:+A-Za-z -]+\n", "", s) return re.sub(r"(Date|Valid-Until): [,0-9:+A-Za-z -]+\n", "", s)
@@ -231,12 +244,14 @@ class CreateMirror20Test(BaseTest):
create mirror: using failing HTTP_PROXY create mirror: using failing HTTP_PROXY
""" """
fixtureGpg = True fixtureGpg = True
outputMatchPrepare = lambda _, s: s.replace('getsockopt: ', '').replace('proxyconnect tcp', 'http: error connecting to proxy http://127.0.0.1:3137')
runCmd = "aptly -architectures='i386' mirror create -keyring=aptlytest.gpg -with-sources mirror20 http://security.debian.org/ wheezy/updates main" runCmd = "aptly -architectures='i386' mirror create -keyring=aptlytest.gpg -with-sources mirror20 http://security.debian.org/ wheezy/updates main"
environmentOverride = {"HTTP_PROXY": "127.0.0.1:3137"} environmentOverride = {"HTTP_PROXY": "127.0.0.1:3137"}
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(_, s):
return s.replace('getsockopt: ', '').replace('proxyconnect tcp', 'http: error connecting to proxy http://127.0.0.1:3137')
class CreateMirror21Test(BaseTest): class CreateMirror21Test(BaseTest):
""" """
@@ -244,7 +259,9 @@ class CreateMirror21Test(BaseTest):
""" """
runCmd = "aptly mirror create -keyring=aptlytest.gpg mirror21 http://pkg.jenkins-ci.org/debian-stable binary/" runCmd = "aptly mirror create -keyring=aptlytest.gpg mirror21 http://pkg.jenkins-ci.org/debian-stable binary/"
fixtureGpg = True fixtureGpg = True
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s)
def outputMatchPrepare(_, s):
return re.sub(r'Signature made .* using', '', s)
def check(self): def check(self):
def removeSHA512(s): def removeSHA512(s):
@@ -285,7 +302,9 @@ class CreateMirror24Test(BaseTest):
""" """
runCmd = "aptly mirror create -ignore-signatures=false -keyring=aptlytest.gpg mirror24 http://security.debian.org/ wheezy/updates main" runCmd = "aptly mirror create -ignore-signatures=false -keyring=aptlytest.gpg mirror24 http://security.debian.org/ wheezy/updates main"
fixtureGpg = True fixtureGpg = True
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s)
def outputMatchPrepare(_, s):
return re.sub(r'Signature made .* using', '', s)
configOverride = { configOverride = {
"gpgDisableVerify": True "gpgDisableVerify": True

View File

@@ -1,12 +1,16 @@
from lib import BaseTest from lib import BaseTest
def sortLines(_, s):
return "\n".join(sorted(s.split("\n")))
class SearchMirror1Test(BaseTest): class SearchMirror1Test(BaseTest):
""" """
search mirror: regular search search mirror: regular search
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly mirror search wheezy-main '$$Architecture (i386), Name (% *-dev)'" runCmd = "aptly mirror search wheezy-main '$$Architecture (i386), Name (% *-dev)'"
@@ -32,7 +36,7 @@ class SearchMirror4Test(BaseTest):
search mirror: with-deps search search mirror: with-deps search
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly mirror search -with-deps wheezy-main 'Name (nginx)'" runCmd = "aptly mirror search -with-deps wheezy-main 'Name (nginx)'"
@@ -41,7 +45,7 @@ class SearchMirror5Test(BaseTest):
search mirror: regular search search mirror: regular search
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly mirror search -format='{{.Package}}#{{.Version}}' wheezy-main '$$Architecture (i386), Name (% *-dev)'" runCmd = "aptly mirror search -format='{{.Package}}#{{.Version}}' wheezy-main '$$Architecture (i386), Name (% *-dev)'"
@@ -50,5 +54,5 @@ class SearchMirror6Test(BaseTest):
search mirror: no query search mirror: no query
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly mirror search -format='{{.Package}}#{{.Version}}' wheezy-main" runCmd = "aptly mirror search -format='{{.Package}}#{{.Version}}' wheezy-main"

View File

@@ -24,7 +24,9 @@ class ShowMirror3Test(BaseTest):
""" """
fixtureDB = True fixtureDB = True
runCmd = "aptly mirror show --with-packages wheezy-contrib" runCmd = "aptly mirror show --with-packages wheezy-contrib"
outputMatchPrepare = lambda _, s: re.sub(r"Last update: [0-9:+A-Za-z -]+\n", "", s)
def outputMatchPrepare(_, s):
return re.sub(r"Last update: [0-9:+A-Za-z -]+\n", "", s)
class ShowMirror4Test(BaseTest): class ShowMirror4Test(BaseTest):
@@ -35,4 +37,6 @@ class ShowMirror4Test(BaseTest):
"aptly mirror create -ignore-signatures -filter='nginx | Priority (required)' -filter-with-deps=true mirror4 http://security.debian.org/ wheezy/updates main" "aptly mirror create -ignore-signatures -filter='nginx | Priority (required)' -filter-with-deps=true mirror4 http://security.debian.org/ wheezy/updates main"
] ]
runCmd = "aptly mirror show mirror4" runCmd = "aptly mirror show mirror4"
outputMatchPrepare = lambda _, s: re.sub(r"(Date|Valid-Until): [,0-9:+A-Za-z -]+\n", "", s)
def outputMatchPrepare(_, s):
return re.sub(r"(Date|Valid-Until): [,0-9:+A-Za-z -]+\n", "", s)

View File

@@ -6,6 +6,10 @@ import inspect
from lib import BaseTest from lib import BaseTest
def filterOutSignature(_, s):
return re.sub(r'Signature made .* using', '', s)
class UpdateMirror1Test(BaseTest): class UpdateMirror1Test(BaseTest):
""" """
update mirrors: regular update update mirrors: regular update
@@ -96,7 +100,7 @@ class UpdateMirror7Test(BaseTest):
"aptly mirror create --keyring=aptlytest.gpg -architectures=amd64 flat https://cloud.r-project.org/bin/linux/debian jessie-cran3/", "aptly mirror create --keyring=aptlytest.gpg -architectures=amd64 flat https://cloud.r-project.org/bin/linux/debian jessie-cran3/",
] ]
runCmd = "aptly mirror update --keyring=aptlytest.gpg flat" runCmd = "aptly mirror update --keyring=aptlytest.gpg flat"
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s) outputMatchPrepare = filterOutSignature
def output_processor(self, output): def output_processor(self, output):
return "\n".join(sorted(output.split("\n"))) return "\n".join(sorted(output.split("\n")))
@@ -112,7 +116,7 @@ class UpdateMirror8Test(BaseTest):
"aptly mirror create --keyring=aptlytest.gpg gnuplot-maverick-src http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick", "aptly mirror create --keyring=aptlytest.gpg gnuplot-maverick-src http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick",
] ]
runCmd = "aptly mirror update --keyring=aptlytest.gpg gnuplot-maverick-src" runCmd = "aptly mirror update --keyring=aptlytest.gpg gnuplot-maverick-src"
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s) outputMatchPrepare = filterOutSignature
class UpdateMirror9Test(BaseTest): class UpdateMirror9Test(BaseTest):
@@ -124,7 +128,7 @@ class UpdateMirror9Test(BaseTest):
"aptly mirror create --keyring=aptlytest.gpg -with-sources flat-src https://cloud.r-project.org/bin/linux/debian jessie-cran3/", "aptly mirror create --keyring=aptlytest.gpg -with-sources flat-src https://cloud.r-project.org/bin/linux/debian jessie-cran3/",
] ]
runCmd = "aptly mirror update --keyring=aptlytest.gpg flat-src" runCmd = "aptly mirror update --keyring=aptlytest.gpg flat-src"
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s) outputMatchPrepare = filterOutSignature
def output_processor(self, output): def output_processor(self, output):
return "\n".join(sorted(output.split("\n"))) return "\n".join(sorted(output.split("\n")))
@@ -139,7 +143,7 @@ class UpdateMirror10Test(BaseTest):
"aptly mirror create -keyring=aptlytest.gpg -with-sources -filter='!(Name (% r-*)), !($$PackageType (source))' flat-src https://cloud.r-project.org/bin/linux/debian jessie-cran3/", "aptly mirror create -keyring=aptlytest.gpg -with-sources -filter='!(Name (% r-*)), !($$PackageType (source))' flat-src https://cloud.r-project.org/bin/linux/debian jessie-cran3/",
] ]
runCmd = "aptly mirror update --keyring=aptlytest.gpg flat-src" runCmd = "aptly mirror update --keyring=aptlytest.gpg flat-src"
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s) outputMatchPrepare = filterOutSignature
def output_processor(self, output): def output_processor(self, output):
return "\n".join(sorted(output.split("\n"))) return "\n".join(sorted(output.split("\n")))
@@ -154,7 +158,7 @@ class UpdateMirror11Test(BaseTest):
fixtureCmds = [ fixtureCmds = [
"aptly mirror create -keyring=aptlytest.gpg -filter='Priority (required), Name (% s*)' -architectures=i386 wheezy-main ftp://ftp.ru.debian.org/debian/ wheezy main", "aptly mirror create -keyring=aptlytest.gpg -filter='Priority (required), Name (% s*)' -architectures=i386 wheezy-main ftp://ftp.ru.debian.org/debian/ wheezy main",
] ]
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s) outputMatchPrepare = filterOutSignature
runCmd = "aptly mirror update -keyring=aptlytest.gpg wheezy-main" runCmd = "aptly mirror update -keyring=aptlytest.gpg wheezy-main"
def output_processor(self, output): def output_processor(self, output):
@@ -171,7 +175,7 @@ class UpdateMirror12Test(BaseTest):
"aptly -architectures=i386,amd64 mirror create -keyring=aptlytest.gpg -filter='$$Source (gnupg)' -with-udebs wheezy http://mirror.yandex.ru/debian/ wheezy main non-free", "aptly -architectures=i386,amd64 mirror create -keyring=aptlytest.gpg -filter='$$Source (gnupg)' -with-udebs wheezy http://mirror.yandex.ru/debian/ wheezy main non-free",
] ]
runCmd = "aptly mirror update -keyring=aptlytest.gpg wheezy" runCmd = "aptly mirror update -keyring=aptlytest.gpg wheezy"
outputMatchPrepare = lambda _, s: re.sub(r'Signature made .* using', '', s) outputMatchPrepare = filterOutSignature
def output_processor(self, output): def output_processor(self, output):
return "\n".join(sorted(output.split("\n"))) return "\n".join(sorted(output.split("\n")))

View File

@@ -1,15 +1,3 @@
""" """
Testing snapshot management Testing snapshot management
""" """
from .create import *
from .show import *
from .list import *
from .verify import *
from .pull import *
from .diff import *
from .merge import *
from .drop import *
from .rename import *
from .search import *
from .filter import *

View File

@@ -2,6 +2,10 @@ import re
from lib import BaseTest from lib import BaseTest
def trimTrailingWhitespace(_, s):
return re.sub(r'\s*$', '', s, flags=re.MULTILINE)
class DiffSnapshot1Test(BaseTest): class DiffSnapshot1Test(BaseTest):
""" """
diff two snapshots: normal diff diff two snapshots: normal diff
@@ -13,8 +17,7 @@ class DiffSnapshot1Test(BaseTest):
"aptly snapshot pull snap1 snap2 snap3 'rsyslog (>= 7.4.4)'" "aptly snapshot pull snap1 snap2 snap3 'rsyslog (>= 7.4.4)'"
] ]
runCmd = "aptly snapshot diff snap1 snap3" runCmd = "aptly snapshot diff snap1 snap3"
# trim trailing whitespace outputMatchPrepare = trimTrailingWhitespace
outputMatchPrepare = lambda _, s: re.sub(r'\s*$', '', s, flags=re.MULTILINE)
class DiffSnapshot2Test(BaseTest): class DiffSnapshot2Test(BaseTest):
@@ -27,8 +30,7 @@ class DiffSnapshot2Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-backports", "aptly snapshot create snap2 from mirror wheezy-backports",
] ]
runCmd = "aptly snapshot diff snap1 snap2" runCmd = "aptly snapshot diff snap1 snap2"
# trim trailing whitespace outputMatchPrepare = trimTrailingWhitespace
outputMatchPrepare = lambda _, s: re.sub(r'\s*$', '', s, flags=re.MULTILINE)
class DiffSnapshot3Test(BaseTest): class DiffSnapshot3Test(BaseTest):
@@ -41,8 +43,7 @@ class DiffSnapshot3Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-backports", "aptly snapshot create snap2 from mirror wheezy-backports",
] ]
runCmd = "aptly snapshot diff -only-matching snap1 snap2" runCmd = "aptly snapshot diff -only-matching snap1 snap2"
# trim trailing whitespace outputMatchPrepare = trimTrailingWhitespace
outputMatchPrepare = lambda _, s: re.sub(r'\s*$', '', s, flags=re.MULTILINE)
class DiffSnapshot4Test(BaseTest): class DiffSnapshot4Test(BaseTest):

View File

@@ -2,6 +2,10 @@ from lib import BaseTest
import re import re
def sortLines(_, output):
return "\n".join(sorted(output.split("\n")))
class PullSnapshot1Test(BaseTest): class PullSnapshot1Test(BaseTest):
""" """
pull snapshot: simple conditions pull snapshot: simple conditions
@@ -12,7 +16,7 @@ class PullSnapshot1Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-non-free", "aptly snapshot create snap2 from mirror wheezy-non-free",
] ]
runCmd = "aptly snapshot pull snap1 snap2 snap3 mame unrar" runCmd = "aptly snapshot pull snap1 snap2 snap3 mame unrar"
outputMatchPrepare = lambda _, output: "\n".join(sorted(output.split("\n"))) outputMatchPrepare = sortLines
def check(self): def check(self):
def remove_created_at(s): def remove_created_at(s):
@@ -32,7 +36,7 @@ class PullSnapshot2Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-backports", "aptly snapshot create snap2 from mirror wheezy-backports",
] ]
runCmd = "aptly snapshot pull snap1 snap2 snap3 'rsyslog (>= 7.4.4)'" runCmd = "aptly snapshot pull snap1 snap2 snap3 'rsyslog (>= 7.4.4)'"
outputMatchPrepare = lambda _, output: "\n".join(sorted(output.split("\n"))) outputMatchPrepare = sortLines
def check(self): def check(self):
def remove_created_at(s): def remove_created_at(s):
@@ -52,7 +56,7 @@ class PullSnapshot3Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-backports", "aptly snapshot create snap2 from mirror wheezy-backports",
] ]
runCmd = "aptly snapshot pull -no-deps snap1 snap2 snap3 'rsyslog (>= 7.4.4)'" runCmd = "aptly snapshot pull -no-deps snap1 snap2 snap3 'rsyslog (>= 7.4.4)'"
outputMatchPrepare = lambda _, output: "\n".join(sorted(output.split("\n"))) outputMatchPrepare = sortLines
def check(self): def check(self):
def remove_created_at(s): def remove_created_at(s):
@@ -72,7 +76,7 @@ class PullSnapshot4Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-backports", "aptly snapshot create snap2 from mirror wheezy-backports",
] ]
runCmd = "aptly snapshot pull -dry-run snap1 snap2 snap3 'rsyslog (>= 7.4.4)'" runCmd = "aptly snapshot pull -dry-run snap1 snap2 snap3 'rsyslog (>= 7.4.4)'"
outputMatchPrepare = lambda _, output: "\n".join(sorted(output.split("\n"))) outputMatchPrepare = sortLines
def check(self): def check(self):
self.check_output() self.check_output()
@@ -116,7 +120,7 @@ class PullSnapshot7Test(BaseTest):
] ]
runCmd = "aptly snapshot pull snap1 snap2 snap1 'rsyslog (>= 7.4.4)'" runCmd = "aptly snapshot pull snap1 snap2 snap1 'rsyslog (>= 7.4.4)'"
expectedCode = 1 expectedCode = 1
outputMatchPrepare = lambda _, output: "\n".join(sorted(output.split("\n"))) outputMatchPrepare = sortLines
class PullSnapshot8Test(BaseTest): class PullSnapshot8Test(BaseTest):
@@ -129,7 +133,7 @@ class PullSnapshot8Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-non-free", "aptly snapshot create snap2 from mirror wheezy-non-free",
] ]
runCmd = "aptly snapshot pull snap1 snap2 snap3 lunar-landing 'mars-landing (>= 1.0)'" runCmd = "aptly snapshot pull snap1 snap2 snap3 lunar-landing 'mars-landing (>= 1.0)'"
outputMatchPrepare = lambda _, output: "\n".join(sorted(output.split("\n"))) outputMatchPrepare = sortLines
def check(self): def check(self):
def remove_created_at(s): def remove_created_at(s):
@@ -187,7 +191,7 @@ class PullSnapshot11Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-backports", "aptly snapshot create snap2 from mirror wheezy-backports",
] ]
runCmd = "aptly snapshot pull -no-remove snap1 snap2 snap3 'rsyslog (>= 7.4.4)'" runCmd = "aptly snapshot pull -no-remove snap1 snap2 snap3 'rsyslog (>= 7.4.4)'"
outputMatchPrepare = lambda _, output: "\n".join(sorted(output.split("\n"))) outputMatchPrepare = sortLines
def check(self): def check(self):
def remove_created_at(s): def remove_created_at(s):
@@ -243,4 +247,4 @@ class PullSnapshot15Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-backports", "aptly snapshot create snap2 from mirror wheezy-backports",
] ]
runCmd = "aptly snapshot pull -dep-verbose-resolve snap1 snap2 snap3 'rsyslog (>= 7.4.4)'" runCmd = "aptly snapshot pull -dep-verbose-resolve snap1 snap2 snap3 'rsyslog (>= 7.4.4)'"
outputMatchPrepare = lambda _, output: "\n".join(sorted(output.split("\n"))) outputMatchPrepare = sortLines

View File

@@ -1,12 +1,16 @@
from lib import BaseTest from lib import BaseTest
def sortLines(_, s):
return "\n".join(sorted(s.split("\n")))
class SearchSnapshot1Test(BaseTest): class SearchSnapshot1Test(BaseTest):
""" """
search snapshot: regular search search snapshot: regular search
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"] fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"]
runCmd = "aptly snapshot search wheezy-main '$$Architecture (i386), Name (% *-dev)'" runCmd = "aptly snapshot search wheezy-main '$$Architecture (i386), Name (% *-dev)'"
@@ -35,7 +39,7 @@ class SearchSnapshot4Test(BaseTest):
""" """
fixtureDB = True fixtureDB = True
fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"] fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"]
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly snapshot search -with-deps wheezy-main 'Name (nginx)'" runCmd = "aptly snapshot search -with-deps wheezy-main 'Name (nginx)'"
@@ -54,15 +58,16 @@ class SearchSnapshot6Test(BaseTest):
search snapshot: with format search snapshot: with format
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"] fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"]
runCmd = "aptly snapshot search -format='{{.Package}}#{{.Version}}' wheezy-main '$$Architecture (i386), Name (% *-dev)'" runCmd = "aptly snapshot search -format='{{.Package}}#{{.Version}}' wheezy-main '$$Architecture (i386), Name (% *-dev)'"
class SearchSnapshot7Test(BaseTest): class SearchSnapshot7Test(BaseTest):
""" """
search snapshot: without query search snapshot: without query
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"] fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"]
runCmd = "aptly snapshot search -format='{{.Package}}#{{.Version}}' wheezy-main" runCmd = "aptly snapshot search -format='{{.Package}}#{{.Version}}' wheezy-main"

View File

@@ -9,7 +9,9 @@ class ShowSnapshot1Test(BaseTest):
fixtureDB = True fixtureDB = True
fixtureCmds = ["aptly snapshot create snap1 from mirror wheezy-non-free"] fixtureCmds = ["aptly snapshot create snap1 from mirror wheezy-non-free"]
runCmd = "aptly snapshot show --with-packages snap1" runCmd = "aptly snapshot show --with-packages snap1"
outputMatchPrepare = lambda _, s: re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s)
def outputMatchPrepare(_, s):
return re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s)
class ShowSnapshot2Test(BaseTest): class ShowSnapshot2Test(BaseTest):
@@ -28,4 +30,6 @@ class ShowSnapshot3Test(BaseTest):
fixtureDB = True fixtureDB = True
fixtureCmds = ["aptly snapshot create snap1 from mirror wheezy-non-free"] fixtureCmds = ["aptly snapshot create snap1 from mirror wheezy-non-free"]
runCmd = "aptly snapshot show snap1" runCmd = "aptly snapshot show snap1"
outputMatchPrepare = lambda _, s: re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s)
def outputMatchPrepare(_, s):
return re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s)

View File

@@ -1,14 +1,3 @@
""" """
Testing publishing snapshots Testing publishing snapshots
""" """
from .fs_endpoint import *
from .drop import *
from .show import *
from .list import *
from .repo import *
from .snapshot import *
from .switch import *
from .update import *
from .s3 import *
from .swift import *

View File

@@ -106,7 +106,6 @@ class FSEndpointPublishSnapshot3Test(FileSystemEndpointTest):
self.check_is_copy('public_copy/pool/main/g/gnuplot/gnuplot-doc_4.6.1-1~maverick2_all.deb') self.check_is_copy('public_copy/pool/main/g/gnuplot/gnuplot-doc_4.6.1-1~maverick2_all.deb')
class FSEndpointPublishSnapshot4Test(FileSystemEndpointTest): class FSEndpointPublishSnapshot4Test(FileSystemEndpointTest):
""" """
publish snapshot: using copy, symlink and hardlink variants publish snapshot: using copy, symlink and hardlink variants
@@ -566,4 +565,3 @@ class FSEndpointPublishSnapshot18Test(FileSystemEndpointTest):
] ]
runCmd = "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=squeeze snap2 filesystem:copysize:" runCmd = "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=squeeze snap2 filesystem:copysize:"
gold_processor = FileSystemEndpointTest.expand_environ gold_processor = FileSystemEndpointTest.expand_environ

View File

@@ -567,7 +567,9 @@ class PublishRepo23Test(BaseTest):
] ]
runCmd = "aptly publish repo -component=main,contrib repo1" runCmd = "aptly publish repo -component=main,contrib repo1"
expectedCode = 2 expectedCode = 2
outputMatchPrepare = lambda _, s: "\n".join([l for l in s.split("\n") if l.startswith("ERROR")])
def outputMatchPrepare(_, s):
return "\n".join([l for l in s.split("\n") if l.startswith("ERROR")])
class PublishRepo24Test(BaseTest): class PublishRepo24Test(BaseTest):
@@ -616,7 +618,9 @@ class PublishRepo26Test(BaseTest):
] ]
runCmd = "aptly publish repo -keyring=${files}/aptly_passphrase.pub -secret-keyring=${files}/aptly_passphrase.sec -passphrase=verysecret -distribution=maverick local-repo" runCmd = "aptly publish repo -keyring=${files}/aptly_passphrase.pub -secret-keyring=${files}/aptly_passphrase.sec -passphrase=verysecret -distribution=maverick local-repo"
gold_processor = BaseTest.expand_environ gold_processor = BaseTest.expand_environ
outputMatchPrepare = lambda _, s: s.replace("gpg: gpg-agent is not available in this session\n", "")
def outputMatchPrepare(_, s):
return s.replace("gpg: gpg-agent is not available in this session\n", "")
def check(self): def check(self):
super(PublishRepo26Test, self).check() super(PublishRepo26Test, self).check()

View File

@@ -833,7 +833,9 @@ class PublishSnapshot32Test(BaseTest):
] ]
runCmd = "aptly publish snapshot -component=main,contrib snap32.1" runCmd = "aptly publish snapshot -component=main,contrib snap32.1"
expectedCode = 2 expectedCode = 2
outputMatchPrepare = lambda _, s: "\n".join([l for l in s.split("\n") if l.startswith("ERROR")])
def outputMatchPrepare(_, s):
return "\n".join([l for l in s.split("\n") if l.startswith("ERROR")])
class PublishSnapshot33Test(BaseTest): class PublishSnapshot33Test(BaseTest):

View File

@@ -369,7 +369,9 @@ class PublishSwitch9Test(BaseTest):
] ]
runCmd = "aptly publish switch -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=a,b maverick snap2" runCmd = "aptly publish switch -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=a,b maverick snap2"
expectedCode = 2 expectedCode = 2
outputMatchPrepare = lambda _, s: "\n".join([l for l in s.split("\n") if l.startswith("ERROR")])
def outputMatchPrepare(_, s):
return "\n".join([l for l in s.split("\n") if l.startswith("ERROR")])
class PublishSwitch10Test(BaseTest): class PublishSwitch10Test(BaseTest):

View File

@@ -8,10 +8,9 @@ import signal
import subprocess import subprocess
import shlex import shlex
import time import time
import errno
from lib import BaseTest from lib import BaseTest
from socket import error as socket_error
class RootDirInaccessible(BaseTest): class RootDirInaccessible(BaseTest):
""" """
@@ -21,12 +20,13 @@ class RootDirInaccessible(BaseTest):
fixturePool = False fixturePool = False
configOverride = { configOverride = {
"rootDir": "/root" # any directory that exists but is not writable "rootDir": "/root" # any directory that exists but is not writable
} }
runCmd = "aptly serve -listen=127.0.0.1:8765" runCmd = "aptly serve -listen=127.0.0.1:8765"
expectedCode = 1 expectedCode = 1
class Serve1Test(BaseTest): class Serve1Test(BaseTest):
""" """
serve public: two publishes, verify HTTP serve public: two publishes, verify HTTP

View File

@@ -1,6 +1,3 @@
""" """
Testing DB operations Testing DB operations
""" """
from .cleanup import *
from .recover import *

View File

@@ -1,17 +1,3 @@
""" """
Testing local repo management Testing local repo management
""" """
from .add import *
from .copy import *
from .create import *
from .drop import *
from .edit import *
from .cmdimport import *
from .list import *
from .move import *
from .remove import *
from .show import *
from .rename import *
from .search import *
from .include import *

View File

@@ -80,15 +80,15 @@ class AddRepo4Test(BaseTest):
os.makedirs(os.path.join(self.tempSrcDir, "02", "03"), 0755) os.makedirs(os.path.join(self.tempSrcDir, "02", "03"), 0755)
shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "libboost-program-options-dev_1.49.0.1_i386.deb"), shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "libboost-program-options-dev_1.49.0.1_i386.deb"),
os.path.join(self.tempSrcDir, "01")) os.path.join(self.tempSrcDir, "01"))
shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1-1.3.dsc"), shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1-1.3.dsc"),
os.path.join(self.tempSrcDir, "02", "03")) os.path.join(self.tempSrcDir, "02", "03"))
shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1.orig.tar.gz"), shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1.orig.tar.gz"),
os.path.join(self.tempSrcDir, "02", "03")) os.path.join(self.tempSrcDir, "02", "03"))
shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1-1.3.diff.gz"), shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1-1.3.diff.gz"),
os.path.join(self.tempSrcDir, "02", "03")) os.path.join(self.tempSrcDir, "02", "03"))
shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1-1.3.diff.gz"), shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1-1.3.diff.gz"),
os.path.join(self.tempSrcDir, "02", "03", "other.file")) os.path.join(self.tempSrcDir, "02", "03", "other.file"))
self.runCmd += self.tempSrcDir self.runCmd += self.tempSrcDir
@@ -124,9 +124,11 @@ class AddRepo5Test(BaseTest):
"aptly repo create -comment=Repo5 -distribution=squeeze repo5", "aptly repo create -comment=Repo5 -distribution=squeeze repo5",
] ]
runCmd = "aptly repo add repo5 " runCmd = "aptly repo add repo5 "
outputMatchPrepare = lambda self, s: s.replace(self.tempSrcDir, "")
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(self, s):
return s.replace(self.tempSrcDir, "")
def prepare(self): def prepare(self):
super(AddRepo5Test, self).prepare() super(AddRepo5Test, self).prepare()
@@ -134,9 +136,9 @@ class AddRepo5Test(BaseTest):
os.makedirs(os.path.join(self.tempSrcDir, "02", "03"), 0755) os.makedirs(os.path.join(self.tempSrcDir, "02", "03"), 0755)
shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1-1.3.dsc"), shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1-1.3.dsc"),
os.path.join(self.tempSrcDir, "02", "03")) os.path.join(self.tempSrcDir, "02", "03"))
shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1.orig.tar.gz"), shutil.copy(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "pyspi_0.6.1.orig.tar.gz"),
os.path.join(self.tempSrcDir, "02", "03")) os.path.join(self.tempSrcDir, "02", "03"))
self.runCmd += self.tempSrcDir self.runCmd += self.tempSrcDir
@@ -175,9 +177,12 @@ class AddRepo8Test(BaseTest):
"aptly repo add repo8 ${files}/pyspi_0.6.1-1.3.dsc", "aptly repo add repo8 ${files}/pyspi_0.6.1-1.3.dsc",
] ]
runCmd = "aptly repo add repo8 ${testfiles}/pyspi_0.6.1-1.3.conflict.dsc" runCmd = "aptly repo add repo8 ${testfiles}/pyspi_0.6.1-1.3.conflict.dsc"
outputMatchPrepare = lambda self, s: s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), "").replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), "")
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(self, s):
return s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), ""). \
replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), "")
def check(self): def check(self):
self.check_output() self.check_output()
self.check_cmd_output("aptly repo show -with-packages repo8", "repo_show") self.check_cmd_output("aptly repo show -with-packages repo8", "repo_show")
@@ -192,9 +197,12 @@ class AddRepo9Test(BaseTest):
] ]
runCmd = "aptly repo add repo9 ${files}/pyspi_0.6.1-1.3.dsc" runCmd = "aptly repo add repo9 ${files}/pyspi_0.6.1-1.3.dsc"
gold_processor = BaseTest.expand_environ gold_processor = BaseTest.expand_environ
outputMatchPrepare = lambda self, s: s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), "")
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(self, s):
return s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), ""). \
replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), "")
def prepare(self): def prepare(self):
super(AddRepo9Test, self).prepare() super(AddRepo9Test, self).prepare()
@@ -227,7 +235,10 @@ class AddRepo11Test(BaseTest):
"aptly repo add repo11 ${files}/pyspi_0.6.1-1.3.dsc", "aptly repo add repo11 ${files}/pyspi_0.6.1-1.3.dsc",
] ]
runCmd = "aptly repo add -force-replace repo11 ${testfiles}/pyspi_0.6.1-1.3.conflict.dsc" runCmd = "aptly repo add -force-replace repo11 ${testfiles}/pyspi_0.6.1-1.3.conflict.dsc"
outputMatchPrepare = lambda self, s: s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), "").replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), "")
def outputMatchPrepare(self, s):
return s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), ""). \
replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), "")
def check(self): def check(self):
self.check_output() self.check_output()
@@ -294,5 +305,8 @@ class AddRepo15Test(BaseTest):
"aptly repo create -comment=Repo15 -distribution=squeeze repo15", "aptly repo create -comment=Repo15 -distribution=squeeze repo15",
] ]
runCmd = "aptly repo add repo15 ${testfiles}" runCmd = "aptly repo add repo15 ${testfiles}"
outputMatchPrepare = lambda self, s: s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), "").replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), "")
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(self, s):
return s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), ""). \
replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), "")

View File

@@ -3,7 +3,8 @@ import inspect
from lib import BaseTest from lib import BaseTest
changesRemove = lambda _, s: s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "changes"), "") def changesRemove(_, s):
return s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "changes"), "")
class CreateRepo1Test(BaseTest): class CreateRepo1Test(BaseTest):

View File

@@ -3,7 +3,8 @@ import inspect
from lib import BaseTest from lib import BaseTest
changesRemove = lambda _, s: s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "changes"), "") def changesRemove(_, s):
return s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "changes"), "")
class EditRepo1Test(BaseTest): class EditRepo1Test(BaseTest):

View File

@@ -5,9 +5,17 @@ import inspect
import re import re
from lib import BaseTest from lib import BaseTest
gpgRemove = lambda _, s: re.sub(r'Signature made .* using|gpgv: keyblock resource .*$|gpgv: Can\'t check signature: .*$', '', s, flags=re.MULTILINE)
changesRemove = lambda _, s: s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "changes"), "") def gpgRemove(_, s):
tempDirRemove = lambda self, s: s.replace(self.tempSrcDir, "") return re.sub(r'Signature made .* using|gpgv: keyblock resource .*$|gpgv: Can\'t check signature: .*$', '', s, flags=re.MULTILINE)
def changesRemove(_, s):
return s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "changes"), "")
def tempDirRemove(self, s):
return s.replace(self.tempSrcDir, "")
class IncludeRepo1Test(BaseTest): class IncludeRepo1Test(BaseTest):
@@ -59,7 +67,9 @@ class IncludeRepo3Test(BaseTest):
] ]
runCmd = "aptly repo include -no-remove-files -keyring=${files}/aptly.pub -repo=my-{{.Distribution} ${changes}" runCmd = "aptly repo include -no-remove-files -keyring=${files}/aptly.pub -repo=my-{{.Distribution} ${changes}"
expectedCode = 1 expectedCode = 1
outputMatchPrepare = lambda _, s: s.replace('; missing space?', '')
def outputMatchPrepare(_, s):
return s.replace('; missing space?', '')
class IncludeRepo4Test(BaseTest): class IncludeRepo4Test(BaseTest):
@@ -126,9 +136,11 @@ class IncludeRepo6Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -keyring=${files}/aptly.pub " runCmd = "aptly repo include -keyring=${files}/aptly.pub "
outputMatchPrepare = lambda self, s: gpgRemove(self, tempDirRemove(self, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(self, s):
return gpgRemove(self, tempDirRemove(self, s))
def prepare(self): def prepare(self):
super(IncludeRepo6Test, self).prepare() super(IncludeRepo6Test, self).prepare()
@@ -161,9 +173,11 @@ class IncludeRepo7Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -keyring=${files}/aptly.pub " runCmd = "aptly repo include -keyring=${files}/aptly.pub "
outputMatchPrepare = lambda self, s: gpgRemove(self, tempDirRemove(self, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(self, s):
return gpgRemove(self, tempDirRemove(self, s))
def prepare(self): def prepare(self):
super(IncludeRepo7Test, self).prepare() super(IncludeRepo7Test, self).prepare()
@@ -191,9 +205,11 @@ class IncludeRepo8Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -keyring=${files}/aptly.pub " runCmd = "aptly repo include -keyring=${files}/aptly.pub "
outputMatchPrepare = lambda self, s: gpgRemove(self, tempDirRemove(self, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(self, s):
return gpgRemove(self, tempDirRemove(self, s))
def prepare(self): def prepare(self):
super(IncludeRepo8Test, self).prepare() super(IncludeRepo8Test, self).prepare()
@@ -224,9 +240,11 @@ class IncludeRepo9Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -keyring=${files}/aptly.pub " runCmd = "aptly repo include -keyring=${files}/aptly.pub "
outputMatchPrepare = lambda self, s: gpgRemove(self, tempDirRemove(self, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(self, s):
return gpgRemove(self, tempDirRemove(self, s))
def prepare(self): def prepare(self):
super(IncludeRepo9Test, self).prepare() super(IncludeRepo9Test, self).prepare()
@@ -258,7 +276,9 @@ class IncludeRepo10Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -ignore-signatures " runCmd = "aptly repo include -ignore-signatures "
outputMatchPrepare = lambda self, s: gpgRemove(self, tempDirRemove(self, s))
def outputMatchPrepare(self, s):
return gpgRemove(self, tempDirRemove(self, s))
def prepare(self): def prepare(self):
super(IncludeRepo10Test, self).prepare() super(IncludeRepo10Test, self).prepare()
@@ -290,7 +310,9 @@ class IncludeRepo11Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -accept-unsigned -keyring=${files}/aptly.pub " runCmd = "aptly repo include -accept-unsigned -keyring=${files}/aptly.pub "
outputMatchPrepare = lambda self, s: gpgRemove(self, tempDirRemove(self, s))
def outputMatchPrepare(self, s):
return gpgRemove(self, tempDirRemove(self, s))
def prepare(self): def prepare(self):
super(IncludeRepo11Test, self).prepare() super(IncludeRepo11Test, self).prepare()
@@ -323,9 +345,11 @@ class IncludeRepo12Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -accept-unsigned -keyring=${files}/aptly.pub " runCmd = "aptly repo include -accept-unsigned -keyring=${files}/aptly.pub "
outputMatchPrepare = lambda self, s: gpgRemove(self, tempDirRemove(self, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(self, s):
return gpgRemove(self, tempDirRemove(self, s))
def prepare(self): def prepare(self):
super(IncludeRepo12Test, self).prepare() super(IncludeRepo12Test, self).prepare()
@@ -358,9 +382,11 @@ class IncludeRepo13Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -uploaders-file=${changes}/uploaders1.json -no-remove-files -keyring=${files}/aptly.pub ${changes}" runCmd = "aptly repo include -uploaders-file=${changes}/uploaders1.json -no-remove-files -keyring=${files}/aptly.pub ${changes}"
outputMatchPrepare = lambda _, s: changesRemove(_, gpgRemove(_, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(_, s):
return changesRemove(_, gpgRemove(_, s))
class IncludeRepo14Test(BaseTest): class IncludeRepo14Test(BaseTest):
""" """
@@ -370,7 +396,9 @@ class IncludeRepo14Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -uploaders-file=${changes}/uploaders2.json -no-remove-files -keyring=${files}/aptly.pub ${changes}" runCmd = "aptly repo include -uploaders-file=${changes}/uploaders2.json -no-remove-files -keyring=${files}/aptly.pub ${changes}"
outputMatchPrepare = lambda _, s: changesRemove(_, gpgRemove(_, s))
def outputMatchPrepare(_, s):
return changesRemove(_, gpgRemove(_, s))
class IncludeRepo15Test(BaseTest): class IncludeRepo15Test(BaseTest):
@@ -381,9 +409,11 @@ class IncludeRepo15Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -uploaders-file=${changes}/uploaders-404.json -no-remove-files -keyring=${files}/aptly.pub ${changes}" runCmd = "aptly repo include -uploaders-file=${changes}/uploaders-404.json -no-remove-files -keyring=${files}/aptly.pub ${changes}"
outputMatchPrepare = lambda _, s: changesRemove(_, gpgRemove(_, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(_, s):
return changesRemove(_, gpgRemove(_, s))
class IncludeRepo16Test(BaseTest): class IncludeRepo16Test(BaseTest):
""" """
@@ -393,9 +423,11 @@ class IncludeRepo16Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -uploaders-file=${changes}/uploaders3.json -no-remove-files -keyring=${files}/aptly.pub ${changes}" runCmd = "aptly repo include -uploaders-file=${changes}/uploaders3.json -no-remove-files -keyring=${files}/aptly.pub ${changes}"
outputMatchPrepare = lambda _, s: changesRemove(_, gpgRemove(_, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(_, s):
return changesRemove(_, gpgRemove(_, s))
class IncludeRepo17Test(BaseTest): class IncludeRepo17Test(BaseTest):
""" """
@@ -405,9 +437,11 @@ class IncludeRepo17Test(BaseTest):
"aptly repo create unstable", "aptly repo create unstable",
] ]
runCmd = "aptly repo include -uploaders-file=${changes}/uploaders4.json -no-remove-files -keyring=${files}/aptly.pub ${changes}" runCmd = "aptly repo include -uploaders-file=${changes}/uploaders4.json -no-remove-files -keyring=${files}/aptly.pub ${changes}"
outputMatchPrepare = lambda _, s: changesRemove(_, gpgRemove(_, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(_, s):
return changesRemove(_, gpgRemove(_, s))
class IncludeRepo18Test(BaseTest): class IncludeRepo18Test(BaseTest):
""" """
@@ -417,7 +451,9 @@ class IncludeRepo18Test(BaseTest):
"aptly repo create -uploaders-file=${changes}/uploaders2.json unstable", "aptly repo create -uploaders-file=${changes}/uploaders2.json unstable",
] ]
runCmd = "aptly repo include -uploaders-file=${changes}/uploaders1.json -no-remove-files -keyring=${files}/aptly.pub ${changes}" runCmd = "aptly repo include -uploaders-file=${changes}/uploaders1.json -no-remove-files -keyring=${files}/aptly.pub ${changes}"
outputMatchPrepare = lambda _, s: changesRemove(_, gpgRemove(_, s))
def outputMatchPrepare(_, s):
return changesRemove(_, gpgRemove(_, s))
class IncludeRepo19Test(BaseTest): class IncludeRepo19Test(BaseTest):
@@ -428,5 +464,7 @@ class IncludeRepo19Test(BaseTest):
"aptly repo create -uploaders-file=${changes}/uploaders1.json unstable", "aptly repo create -uploaders-file=${changes}/uploaders1.json unstable",
] ]
runCmd = "aptly repo include -no-remove-files -keyring=${files}/aptly.pub ${changes}" runCmd = "aptly repo include -no-remove-files -keyring=${files}/aptly.pub ${changes}"
outputMatchPrepare = lambda _, s: changesRemove(_, gpgRemove(_, s))
expectedCode = 1 expectedCode = 1
def outputMatchPrepare(_, s):
return changesRemove(_, gpgRemove(_, s))

View File

@@ -61,4 +61,3 @@ class RemoveRepo4Test(BaseTest):
def output_processor(self, output): def output_processor(self, output):
return "\n".join(sorted(output.split("\n"))) return "\n".join(sorted(output.split("\n")))

View File

@@ -1,12 +1,16 @@
from lib import BaseTest from lib import BaseTest
def sortLines(_, s):
return "\n".join(sorted(s.split("\n")))
class SearchRepo1Test(BaseTest): class SearchRepo1Test(BaseTest):
""" """
search repo: regular search search repo: regular search
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"] fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"]
runCmd = "aptly repo search wheezy-main '$$Architecture (i386), Name (% *-dev)'" runCmd = "aptly repo search wheezy-main '$$Architecture (i386), Name (% *-dev)'"
@@ -35,7 +39,7 @@ class SearchRepo4Test(BaseTest):
""" """
fixtureDB = True fixtureDB = True
fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"] fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"]
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly repo search -with-deps wheezy-main 'Name (nginx)'" runCmd = "aptly repo search -with-deps wheezy-main 'Name (nginx)'"
@@ -44,15 +48,16 @@ class SearchRepo5Test(BaseTest):
search repo: with -format search repo: with -format
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"] fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"]
runCmd = "aptly repo search -format='{{.Package}}#{{.Version}}' wheezy-main '$$Architecture (i386), Name (% *-dev)'" runCmd = "aptly repo search -format='{{.Package}}#{{.Version}}' wheezy-main '$$Architecture (i386), Name (% *-dev)'"
class SearchRepo6Test(BaseTest): class SearchRepo6Test(BaseTest):
""" """
search repo: without query search repo: without query
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"] fixtureCmds = ["aptly repo create wheezy-main", "aptly repo import wheezy-main wheezy-main Name"]
runCmd = "aptly repo search wheezy-main" runCmd = "aptly repo search wheezy-main"

View File

@@ -1,5 +1,3 @@
""" """
Test aptly task run Test aptly task run
""" """
from .run import *

View File

@@ -1,6 +1,3 @@
""" """
Testing package subcommands Testing package subcommands
""" """
from .search import *
from .show import *

View File

@@ -1,12 +1,16 @@
from lib import BaseTest from lib import BaseTest
def sortLines(_, s):
return "\n".join(sorted(s.split("\n")))
class SearchPackage1Test(BaseTest): class SearchPackage1Test(BaseTest):
""" """
search package: regular search search package: regular search
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly package search '$$Architecture (i386), Name (% *-dev)'" runCmd = "aptly package search '$$Architecture (i386), Name (% *-dev)'"
@@ -31,7 +35,7 @@ class SearchPackage4Test(BaseTest):
search package: by dependency search package: by dependency
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly package search coreutils" runCmd = "aptly package search coreutils"
@@ -40,13 +44,14 @@ class SearchPackage5Test(BaseTest):
search package: with format search package: with format
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly package search -format='{{.Package}}#{{.Version}}' '$$Architecture (i386), Name (% *-dev)'" runCmd = "aptly package search -format='{{.Package}}#{{.Version}}' '$$Architecture (i386), Name (% *-dev)'"
class SearchPackage6Test(BaseTest): class SearchPackage6Test(BaseTest):
""" """
search package: no query search package: no query
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly package search" runCmd = "aptly package search"

View File

@@ -1,12 +1,16 @@
from lib import BaseTest from lib import BaseTest
def sortLines(_, s):
return "\n".join(sorted(s.split("\n")))
class ShowPackage1Test(BaseTest): class ShowPackage1Test(BaseTest):
""" """
show package: regular show show package: regular show
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly package show 'Name (% nginx-extras*)'" runCmd = "aptly package show 'Name (% nginx-extras*)'"
@@ -22,7 +26,7 @@ class ShowPackage3Test(BaseTest):
show package: by key show package: by key
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly package show nginx-full_1.2.1-2.2+wheezy2_amd64" runCmd = "aptly package show nginx-full_1.2.1-2.2+wheezy2_amd64"
@@ -31,7 +35,7 @@ class ShowPackage4Test(BaseTest):
show package: with files show package: with files
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
gold_processor = BaseTest.expand_environ gold_processor = BaseTest.expand_environ
runCmd = "aptly package show -with-files nginx-full_1.2.1-2.2+wheezy2_amd64" runCmd = "aptly package show -with-files nginx-full_1.2.1-2.2+wheezy2_amd64"
@@ -41,7 +45,7 @@ class ShowPackage5Test(BaseTest):
show package: with inclusion show package: with inclusion
""" """
fixtureDB = True fixtureDB = True
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly package show -with-references nginx-full_1.2.1-2.2+wheezy2_amd64" runCmd = "aptly package show -with-references nginx-full_1.2.1-2.2+wheezy2_amd64"
@@ -58,7 +62,7 @@ class ShowPackage6Test(BaseTest):
"aptly repo create repo1", "aptly repo create repo1",
"aptly repo import wheezy-main repo1 nginx", "aptly repo import wheezy-main repo1 nginx",
] ]
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly package show -with-references nginx-full_1.2.1-2.2+wheezy2_amd64" runCmd = "aptly package show -with-references nginx-full_1.2.1-2.2+wheezy2_amd64"
@@ -72,5 +76,5 @@ class ShowPackage7Test(BaseTest):
"aptly repo add a ${files}", "aptly repo add a ${files}",
"aptly repo add b ${testfiles}" "aptly repo add b ${testfiles}"
] ]
outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) outputMatchPrepare = sortLines
runCmd = "aptly package show -with-references \"pyspi (0.6.1-1.3)\"" runCmd = "aptly package show -with-references \"pyspi (0.6.1-1.3)\""

View File

@@ -1,13 +1,3 @@
""" """
Testing aptly REST API Testing aptly REST API
""" """
from .repos import *
from .files import *
from .publish import *
from .version import *
from .graph import *
from .snapshots import *
from .packages import *
from .unix_socket import *
from .systemd_handover import *

View File

@@ -31,10 +31,10 @@ class GraphAPITest(APITest):
horizontal = self.get("/api/graph.svg?layout=horizontal").content horizontal = self.get("/api/graph.svg?layout=horizontal").content
vertical = self.get("/api/graph.svg?layout=vertical").content vertical = self.get("/api/graph.svg?layout=vertical").content
horizontalWidth = int(ET.fromstring(horizontal).get('width').replace("pt","")) horizontalWidth = int(ET.fromstring(horizontal).get('width').replace("pt", ""))
horizontalHeight = int(ET.fromstring(horizontal).get('height').replace("pt","")) horizontalHeight = int(ET.fromstring(horizontal).get('height').replace("pt", ""))
verticalWidth = int(ET.fromstring(vertical).get('width').replace("pt","")) verticalWidth = int(ET.fromstring(vertical).get('width').replace("pt", ""))
verticalHeight = int(ET.fromstring(vertical).get('height').replace("pt","")) verticalHeight = int(ET.fromstring(vertical).get('height').replace("pt", ""))
self.check_gt(horizontalWidth, verticalWidth) self.check_gt(horizontalWidth, verticalWidth)
self.check_gt(verticalHeight, horizontalHeight) self.check_gt(verticalHeight, horizontalHeight)

View File

@@ -24,11 +24,11 @@ class PackagesAPITestShow(APITest):
self.check_equal(resp.json(), { self.check_equal(resp.json(), {
'Architecture': 'any', 'Architecture': 'any',
'Binary': 'python-at-spi', 'Binary': 'python-at-spi',
'Build-Depends': 'debhelper (>= 5), cdbs, libatspi-dev, python-pyrex, python-support (>= 0.4), python-all-dev, libx11-dev', 'Build-Depends': 'debhelper (>= 5), cdbs, libatspi-dev, python-pyrex, python-support (>= 0.4), python-all-dev, libx11-dev', # noqa
'Checksums-Sha1': ' 95a2468e4bbce730ba286f2211fa41861b9f1d90 3456 pyspi_0.6.1-1.3.diff.gz\n 56c8a9b1f4ab636052be8966690998cbe865cd6c 1782 pyspi_0.6.1-1.3.dsc\n 9694b80acc171c0a5bc99f707933864edfce555e 29063 pyspi_0.6.1.orig.tar.gz\n', 'Checksums-Sha1': ' 95a2468e4bbce730ba286f2211fa41861b9f1d90 3456 pyspi_0.6.1-1.3.diff.gz\n 56c8a9b1f4ab636052be8966690998cbe865cd6c 1782 pyspi_0.6.1-1.3.dsc\n 9694b80acc171c0a5bc99f707933864edfce555e 29063 pyspi_0.6.1.orig.tar.gz\n', # noqa
'Checksums-Sha256': ' 2e770b28df948f3197ed0b679bdea99f3f2bf745e9ddb440c677df9c3aeaee3c 3456 pyspi_0.6.1-1.3.diff.gz\n d494aaf526f1ec6b02f14c2f81e060a5722d6532ddc760ec16972e45c2625989 1782 pyspi_0.6.1-1.3.dsc\n 64069ee828c50b1c597d10a3fefbba279f093a4723965388cdd0ac02f029bfb9 29063 pyspi_0.6.1.orig.tar.gz\n', 'Checksums-Sha256': ' 2e770b28df948f3197ed0b679bdea99f3f2bf745e9ddb440c677df9c3aeaee3c 3456 pyspi_0.6.1-1.3.diff.gz\n d494aaf526f1ec6b02f14c2f81e060a5722d6532ddc760ec16972e45c2625989 1782 pyspi_0.6.1-1.3.dsc\n 64069ee828c50b1c597d10a3fefbba279f093a4723965388cdd0ac02f029bfb9 29063 pyspi_0.6.1.orig.tar.gz\n', # noqa
'Checksums-Sha512': ' 384b5e94b4113262e41bda1a2563f4f439cb8c97f43e2caefe16d7626718c21b36d3145b915eed24053eaa7fe3b6186494a87a3fcf9627f6e653b54bb3caa897 3456 pyspi_0.6.1-1.3.diff.gz\n fde06b7dc5762a04986d0669420822f6a1e82b195322ae9cbd2dae40bda557c57ad77fe3546007ea645f801c4cd30ef4eb0e96efb2dee6b71c4c9a187d643683 1782 pyspi_0.6.1-1.3.dsc\n c278f52953203292bcc828bcf05aee456b160f91716f51ec1a1dbbcdb8b08fc29183d0a1135629fc0ebe86a3e84cedc685c3aa1714b70cc5db8877d40e754d7f 29063 pyspi_0.6.1.orig.tar.gz\n', 'Checksums-Sha512': ' 384b5e94b4113262e41bda1a2563f4f439cb8c97f43e2caefe16d7626718c21b36d3145b915eed24053eaa7fe3b6186494a87a3fcf9627f6e653b54bb3caa897 3456 pyspi_0.6.1-1.3.diff.gz\n fde06b7dc5762a04986d0669420822f6a1e82b195322ae9cbd2dae40bda557c57ad77fe3546007ea645f801c4cd30ef4eb0e96efb2dee6b71c4c9a187d643683 1782 pyspi_0.6.1-1.3.dsc\n c278f52953203292bcc828bcf05aee456b160f91716f51ec1a1dbbcdb8b08fc29183d0a1135629fc0ebe86a3e84cedc685c3aa1714b70cc5db8877d40e754d7f 29063 pyspi_0.6.1.orig.tar.gz\n', # noqa
'Files': ' 22ff26db69b73d3438fdde21ab5ba2f1 3456 pyspi_0.6.1-1.3.diff.gz\n b72cb94699298a117b7c82641c68b6fd 1782 pyspi_0.6.1-1.3.dsc\n def336bd566ea688a06ec03db7ccf1f4 29063 pyspi_0.6.1.orig.tar.gz\n', 'Files': ' 22ff26db69b73d3438fdde21ab5ba2f1 3456 pyspi_0.6.1-1.3.diff.gz\n b72cb94699298a117b7c82641c68b6fd 1782 pyspi_0.6.1-1.3.dsc\n def336bd566ea688a06ec03db7ccf1f4 29063 pyspi_0.6.1.orig.tar.gz\n', # noqa
'FilesHash': '3a8b37cbd9a3559e', 'FilesHash': '3a8b37cbd9a3559e',
'Format': '1.0', 'Format': '1.0',
'Homepage': 'http://people.redhat.com/zcerza/dogtail', 'Homepage': 'http://people.redhat.com/zcerza/dogtail',

View File

@@ -21,9 +21,9 @@ class PublishAPITestRepo(APITest):
d = self.random_name() d = self.random_name()
self.check_equal(self.upload("/api/files/" + d, self.check_equal(self.upload("/api/files/" + d,
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200) self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200)
@@ -150,10 +150,11 @@ class PublishUpdateAPITestRepo(APITest):
self.check_equal(self.post("/api/repos", json={"Name": repo_name, "DefaultDistribution": "wheezy"}).status_code, 201) self.check_equal(self.post("/api/repos", json={"Name": repo_name, "DefaultDistribution": "wheezy"}).status_code, 201)
d = self.random_name() d = self.random_name()
self.check_equal(self.upload("/api/files/" + d, self.check_equal(
"pyspi_0.6.1-1.3.dsc", self.upload("/api/files/" + d,
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", "pyspi_0.6.1-1.3.dsc",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200) self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200)
prefix = self.random_name() prefix = self.random_name()
@@ -214,10 +215,11 @@ class PublishSwitchAPITestRepo(APITest):
self.check_equal(self.post("/api/repos", json={"Name": repo_name, "DefaultDistribution": "wheezy"}).status_code, 201) self.check_equal(self.post("/api/repos", json={"Name": repo_name, "DefaultDistribution": "wheezy"}).status_code, 201)
d = self.random_name() d = self.random_name()
self.check_equal(self.upload("/api/files/" + d, self.check_equal(
"pyspi_0.6.1-1.3.dsc", self.upload("/api/files/" + d,
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", "pyspi_0.6.1-1.3.dsc",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200) self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200)
snapshot1_name = self.random_name() snapshot1_name = self.random_name()

View File

@@ -186,10 +186,11 @@ class ReposAPITestShowQuery(APITest):
self.check_equal(self.post("/api/repos", json={"Name": repo_name, "Comment": "fun repo"}).status_code, 201) self.check_equal(self.post("/api/repos", json={"Name": repo_name, "Comment": "fun repo"}).status_code, 201)
d = self.random_name() d = self.random_name()
self.check_equal(self.upload("/api/files/" + d, self.check_equal(
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", self.upload("/api/files/" + d,
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200) self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200)
self.check_equal(sorted(self.get("/api/repos/" + repo_name + "/packages", params={"q": "pyspi"}).json()), self.check_equal(sorted(self.get("/api/repos/" + repo_name + "/packages", params={"q": "pyspi"}).json()),
@@ -217,10 +218,11 @@ class ReposAPITestAddMultiple(APITest):
self.check_equal(self.post("/api/repos", json={"Name": repo_name, "Comment": "fun repo"}).status_code, 201) self.check_equal(self.post("/api/repos", json={"Name": repo_name, "Comment": "fun repo"}).status_code, 201)
d = self.random_name() d = self.random_name()
self.check_equal(self.upload("/api/files/" + d, self.check_equal(
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", self.upload("/api/files/" + d,
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d + "/pyspi_0.6.1-1.3.dsc", self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d + "/pyspi_0.6.1-1.3.dsc",
params={"noRemove": 1}).status_code, 200) params={"noRemove": 1}).status_code, 200)
@@ -244,10 +246,11 @@ class ReposAPITestPackagesAddDelete(APITest):
self.check_equal(self.post("/api/repos", json={"Name": repo_name, "Comment": "fun repo"}).status_code, 201) self.check_equal(self.post("/api/repos", json={"Name": repo_name, "Comment": "fun repo"}).status_code, 201)
d = self.random_name() d = self.random_name()
self.check_equal(self.upload("/api/files/" + d, self.check_equal(
"libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", self.upload("/api/files/" + d,
"pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz",
"pyspi-0.6.1-1.3.stripped.dsc").status_code, 200)
self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200) self.check_equal(self.post("/api/repos/" + repo_name + "/file/" + d).status_code, 200)

View File

@@ -101,7 +101,6 @@ class SnapshotsAPITestCreateFromRepo(APITest):
self.check_equal([], self.check_equal([],
self.get("/api/snapshots/" + snapshot_name + "/packages", params={"format": "details"}).json()) self.get("/api/snapshots/" + snapshot_name + "/packages", params={"format": "details"}).json())
snapshot_name = self.random_name() snapshot_name = self.random_name()
d = self.random_name() d = self.random_name()
self.check_equal(self.upload("/api/files/" + d, self.check_equal(self.upload("/api/files/" + d,