mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-31 04:30:44 +00:00
Tests for publish list API + verify that publishing actually creates files. #116
This commit is contained in:
@@ -267,6 +267,10 @@ class BaseTest(object):
|
|||||||
if a != b:
|
if a != b:
|
||||||
self.verify_match(a, b, match_prepare=pprint.pformat)
|
self.verify_match(a, b, match_prepare=pprint.pformat)
|
||||||
|
|
||||||
|
def check_in(self, item, l):
|
||||||
|
if not item in l:
|
||||||
|
raise Exception("item %r not in %r", item, l)
|
||||||
|
|
||||||
def check_subset(self, a, b):
|
def check_subset(self, a, b):
|
||||||
diff = ''
|
diff = ''
|
||||||
for k, v in a.items():
|
for k, v in a.items():
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ DefaultSigningOptions = {
|
|||||||
|
|
||||||
class PublishAPITestRepo(APITest):
|
class PublishAPITestRepo(APITest):
|
||||||
"""
|
"""
|
||||||
POST /publish/:prefix (local repos)
|
POST /publish/:prefix (local repos), GET /publish
|
||||||
"""
|
"""
|
||||||
fixtureGpg = True
|
fixtureGpg = True
|
||||||
|
|
||||||
@@ -35,8 +35,7 @@ class PublishAPITestRepo(APITest):
|
|||||||
"Sources": [{"Name": repo_name}],
|
"Sources": [{"Name": repo_name}],
|
||||||
"Signing": DefaultSigningOptions,
|
"Signing": DefaultSigningOptions,
|
||||||
})
|
})
|
||||||
self.check_equal(resp.status_code, 201)
|
repo_expected = {
|
||||||
self.check_equal(resp.json(), {
|
|
||||||
'Architectures': ['i386', 'source'],
|
'Architectures': ['i386', 'source'],
|
||||||
'Distribution': 'wheezy',
|
'Distribution': 'wheezy',
|
||||||
'Label': '',
|
'Label': '',
|
||||||
@@ -44,7 +43,19 @@ class PublishAPITestRepo(APITest):
|
|||||||
'Prefix': prefix,
|
'Prefix': prefix,
|
||||||
'SourceKind': 'local',
|
'SourceKind': 'local',
|
||||||
'Sources': [{'Component': 'main', 'Name': repo_name}],
|
'Sources': [{'Component': 'main', 'Name': repo_name}],
|
||||||
'Storage': ''})
|
'Storage': ''}
|
||||||
|
|
||||||
|
self.check_equal(resp.status_code, 201)
|
||||||
|
self.check_equal(resp.json(), repo_expected)
|
||||||
|
|
||||||
|
all_repos = self.get("/api/publish")
|
||||||
|
self.check_equal(all_repos.status_code, 200)
|
||||||
|
self.check_in(repo_expected, all_repos.json())
|
||||||
|
|
||||||
|
self.check_exists("public/" + prefix + "/dists/wheezy/Release")
|
||||||
|
self.check_exists("public/" + prefix + "/dists/wheezy/main/binary-i386/Packages")
|
||||||
|
self.check_exists("public/" + prefix + "/dists/wheezy/main/source/Sources")
|
||||||
|
self.check_exists("public/" + prefix + "/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb")
|
||||||
|
|
||||||
# publishing under root, custom distribution, architectures
|
# publishing under root, custom distribution, architectures
|
||||||
distribution = self.random_name()
|
distribution = self.random_name()
|
||||||
@@ -56,8 +67,7 @@ class PublishAPITestRepo(APITest):
|
|||||||
"Distribution": distribution,
|
"Distribution": distribution,
|
||||||
"Architectures": ["i386", "amd64"],
|
"Architectures": ["i386", "amd64"],
|
||||||
})
|
})
|
||||||
self.check_equal(resp.status_code, 201)
|
repo2_expected = {
|
||||||
self.check_equal(resp.json(), {
|
|
||||||
'Architectures': ['amd64', 'i386'],
|
'Architectures': ['amd64', 'i386'],
|
||||||
'Distribution': distribution,
|
'Distribution': distribution,
|
||||||
'Label': '',
|
'Label': '',
|
||||||
@@ -65,12 +75,24 @@ class PublishAPITestRepo(APITest):
|
|||||||
'Prefix': ".",
|
'Prefix': ".",
|
||||||
'SourceKind': 'local',
|
'SourceKind': 'local',
|
||||||
'Sources': [{'Component': 'main', 'Name': repo_name}],
|
'Sources': [{'Component': 'main', 'Name': repo_name}],
|
||||||
'Storage': ''})
|
'Storage': ''}
|
||||||
|
self.check_equal(resp.status_code, 201)
|
||||||
|
self.check_equal(resp.json(), repo2_expected)
|
||||||
|
|
||||||
|
self.check_exists("public/dists/" + distribution + "/Release")
|
||||||
|
self.check_exists("public/dists/" + distribution + "/main/binary-i386/Packages")
|
||||||
|
self.check_exists("public/dists/" + distribution + "/main/binary-amd64/Packages")
|
||||||
|
self.check_exists("public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb")
|
||||||
|
|
||||||
|
all_repos = self.get("/api/publish")
|
||||||
|
self.check_equal(all_repos.status_code, 200)
|
||||||
|
self.check_in(repo_expected, all_repos.json())
|
||||||
|
self.check_in(repo2_expected, all_repos.json())
|
||||||
|
|
||||||
|
|
||||||
class PublishSnapshotAPITest(APITest):
|
class PublishSnapshotAPITest(APITest):
|
||||||
"""
|
"""
|
||||||
POST /publish/:prefix (snapshots)
|
POST /publish/:prefix (snapshots), GET /publish
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
@@ -107,3 +129,7 @@ class PublishSnapshotAPITest(APITest):
|
|||||||
'SourceKind': 'snapshot',
|
'SourceKind': 'snapshot',
|
||||||
'Sources': [{'Component': 'main', 'Name': snapshot_name}],
|
'Sources': [{'Component': 'main', 'Name': snapshot_name}],
|
||||||
'Storage': ''})
|
'Storage': ''})
|
||||||
|
|
||||||
|
self.check_exists("public/" + prefix + "/dists/squeeze/Release")
|
||||||
|
self.check_exists("public/" + prefix + "/dists/squeeze/main/binary-i386/Packages")
|
||||||
|
self.check_exists("public/" + prefix + "/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb")
|
||||||
|
|||||||
Reference in New Issue
Block a user