mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-20 19:38:39 +00:00
@@ -12,16 +12,16 @@ class GraphAPITest(APITest):
|
||||
def check(self):
|
||||
resp = self.get("/api/graph.png")
|
||||
self.check_equal(resp.headers["Content-Type"], "image/png")
|
||||
self.check_equal(resp.content[:4], '\x89PNG')
|
||||
self.check_equal(resp.content[:4], b'\x89PNG')
|
||||
|
||||
self.check_equal(self.post("/api/repos", json={"Name": "xyz", "Comment": "fun repo"}).status_code, 201)
|
||||
resp = self.get("/api/graph.svg")
|
||||
self.check_equal(resp.headers["Content-Type"], "image/svg+xml")
|
||||
self.check_equal(resp.content[:4], '<?xm')
|
||||
self.check_equal(resp.content[:4], b'<?xm')
|
||||
|
||||
resp = self.get("/api/graph.dot")
|
||||
self.check_equal(resp.headers["Content-Type"], "text/plain; charset=utf-8")
|
||||
self.check_equal(resp.content[:13], 'digraph aptly')
|
||||
self.check_equal(resp.content[:13], b'digraph aptly')
|
||||
|
||||
# basic test of layout:
|
||||
# horizontal should be wider than vertical
|
||||
|
||||
@@ -10,11 +10,11 @@ class MirrorsAPITestCreateShow(APITest):
|
||||
|
||||
def check(self):
|
||||
mirror_name = self.random_name()
|
||||
mirror_desc = {u'Name': mirror_name,
|
||||
u'ArchiveURL': 'http://security.debian.org/',
|
||||
u'Architectures': ['amd64'],
|
||||
u'Components': ['main'],
|
||||
u'Distribution': 'wheezy/updates'}
|
||||
mirror_desc = {'Name': mirror_name,
|
||||
'ArchiveURL': 'http://security.debian.org/',
|
||||
'Architectures': ['amd64'],
|
||||
'Components': ['main'],
|
||||
'Distribution': 'wheezy/updates'}
|
||||
|
||||
resp = self.post("/api/mirrors", json=mirror_desc)
|
||||
self.check_equal(resp.status_code, 400)
|
||||
@@ -22,17 +22,17 @@ class MirrorsAPITestCreateShow(APITest):
|
||||
'error': 'unable to fetch mirror: verification of detached signature failed: exit status 2',
|
||||
}, resp.json())
|
||||
|
||||
mirror_desc[u'IgnoreSignatures'] = True
|
||||
mirror_desc['IgnoreSignatures'] = True
|
||||
resp = self.post("/api/mirrors", json=mirror_desc)
|
||||
self.check_equal(resp.status_code, 201)
|
||||
|
||||
resp = self.get("/api/mirrors/" + mirror_name)
|
||||
self.check_equal(resp.status_code, 200)
|
||||
self.check_subset({u'Name': mirror_name,
|
||||
u'ArchiveRoot': 'http://security.debian.org/',
|
||||
u'Architectures': ['amd64'],
|
||||
u'Components': ['main'],
|
||||
u'Distribution': 'wheezy/updates'}, resp.json())
|
||||
self.check_subset({'Name': mirror_name,
|
||||
'ArchiveRoot': 'http://security.debian.org/',
|
||||
'Architectures': ['amd64'],
|
||||
'Components': ['main'],
|
||||
'Distribution': 'wheezy/updates'}, resp.json())
|
||||
|
||||
resp = self.get("/api/mirrors/" + mirror_desc["Name"] + "/packages")
|
||||
self.check_equal(resp.status_code, 404)
|
||||
@@ -44,12 +44,12 @@ class MirrorsAPITestCreateUpdate(APITest):
|
||||
"""
|
||||
def check(self):
|
||||
mirror_name = self.random_name()
|
||||
mirror_desc = {u'Name': mirror_name,
|
||||
u'ArchiveURL': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
u'Distribution': 'wheezy',
|
||||
u'Components': ['main']}
|
||||
mirror_desc = {'Name': mirror_name,
|
||||
'ArchiveURL': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
'Distribution': 'wheezy',
|
||||
'Components': ['main']}
|
||||
|
||||
mirror_desc[u'IgnoreSignatures'] = True
|
||||
mirror_desc['IgnoreSignatures'] = True
|
||||
resp = self.post("/api/mirrors", json=mirror_desc)
|
||||
self.check_equal(resp.status_code, 201)
|
||||
|
||||
@@ -68,9 +68,9 @@ class MirrorsAPITestCreateUpdate(APITest):
|
||||
|
||||
resp = self.get("/api/mirrors/" + mirror_desc["Name"])
|
||||
self.check_equal(resp.status_code, 200)
|
||||
self.check_subset({u'Name': mirror_desc["Name"],
|
||||
u'ArchiveRoot': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
u'Distribution': 'wheezy'}, resp.json())
|
||||
self.check_subset({'Name': mirror_desc["Name"],
|
||||
'ArchiveRoot': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
'Distribution': 'wheezy'}, resp.json())
|
||||
|
||||
resp = self.get("/api/mirrors/" + mirror_desc["Name"] + "/packages")
|
||||
self.check_equal(resp.status_code, 200)
|
||||
@@ -82,11 +82,11 @@ class MirrorsAPITestCreateDelete(APITest):
|
||||
"""
|
||||
def check(self):
|
||||
mirror_name = self.random_name()
|
||||
mirror_desc = {u'Name': mirror_name,
|
||||
u'ArchiveURL': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
u'IgnoreSignatures': True,
|
||||
u'Distribution': 'wheezy',
|
||||
u'Components': ['main']}
|
||||
mirror_desc = {'Name': mirror_name,
|
||||
'ArchiveURL': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
'IgnoreSignatures': True,
|
||||
'Distribution': 'wheezy',
|
||||
'Components': ['main']}
|
||||
|
||||
resp = self.post("/api/mirrors", json=mirror_desc)
|
||||
self.check_equal(resp.status_code, 201)
|
||||
@@ -105,11 +105,11 @@ class MirrorsAPITestCreateList(APITest):
|
||||
count = len(resp.json())
|
||||
|
||||
mirror_name = self.random_name()
|
||||
mirror_desc = {u'Name': mirror_name,
|
||||
u'ArchiveURL': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
u'IgnoreSignatures': True,
|
||||
u'Distribution': 'wheezy',
|
||||
u'Components': ['main']}
|
||||
mirror_desc = {'Name': mirror_name,
|
||||
'ArchiveURL': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
'IgnoreSignatures': True,
|
||||
'Distribution': 'wheezy',
|
||||
'Components': ['main']}
|
||||
|
||||
resp = self.post("/api/mirrors", json=mirror_desc)
|
||||
self.check_equal(resp.status_code, 201)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import urllib
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from api_lib import APITest
|
||||
|
||||
|
||||
@@ -19,7 +22,7 @@ class PackagesAPITestShow(APITest):
|
||||
self.check_equal(resp.json()['State'], 2)
|
||||
|
||||
# get information about package
|
||||
resp = self.get("/api/packages/" + urllib.quote('Psource pyspi 0.6.1-1.3 3a8b37cbd9a3559e'))
|
||||
resp = self.get("/api/packages/" + urllib.parse.quote('Psource pyspi 0.6.1-1.3 3a8b37cbd9a3559e'))
|
||||
self.check_equal(resp.status_code, 200)
|
||||
self.check_equal(resp.json(), {
|
||||
'Architecture': 'any',
|
||||
@@ -40,5 +43,5 @@ class PackagesAPITestShow(APITest):
|
||||
'Vcs-Svn': 'svn://svn.tribulaciones.org/srv/svn/pyspi/trunk',
|
||||
'Version': '0.6.1-1.3'})
|
||||
|
||||
resp = self.get("/api/packages/" + urllib.quote('Pamd64 no-such-package 1.0 3a8b37cbd9a3559e'))
|
||||
resp = self.get("/api/packages/" + urllib.parse.quote('Pamd64 no-such-package 1.0 3a8b37cbd9a3559e'))
|
||||
self.check_equal(resp.status_code, 404)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from api_lib import APITest
|
||||
from publish import DefaultSigningOptions
|
||||
from .publish import DefaultSigningOptions
|
||||
|
||||
|
||||
class ReposAPITestCreateShow(APITest):
|
||||
@@ -8,10 +8,10 @@ class ReposAPITestCreateShow(APITest):
|
||||
"""
|
||||
def check(self):
|
||||
repo_name = self.random_name()
|
||||
repo_desc = {u'Comment': u'fun repo',
|
||||
u'DefaultComponent': u'',
|
||||
u'DefaultDistribution': u'',
|
||||
u'Name': repo_name}
|
||||
repo_desc = {'Comment': 'fun repo',
|
||||
'DefaultComponent': '',
|
||||
'DefaultDistribution': '',
|
||||
'Name': repo_name}
|
||||
|
||||
resp = self.post("/api/repos", json={"Name": repo_name, "Comment": "fun repo"})
|
||||
self.check_equal(resp.json(), repo_desc)
|
||||
@@ -101,10 +101,10 @@ class ReposAPITestAdd(APITest):
|
||||
resp = self.get("/api/tasks/" + str(resp.json()['ID']) + "/output")
|
||||
self.check_equal(resp.status_code, 200)
|
||||
|
||||
self.check_in("Added: pyspi_0.6.1-1.3_source added", resp.content)
|
||||
self.check_equal("Removed: " in resp.content, False)
|
||||
self.check_equal("Failed files: " in resp.content, False)
|
||||
self.check_equal("Warnings: " in resp.content, False)
|
||||
self.check_in(b"Added: pyspi_0.6.1-1.3_source added", resp.content)
|
||||
self.check_not_in(b"Removed: ", resp.content)
|
||||
self.check_not_in(b"Failed files: ", resp.content)
|
||||
self.check_not_in(b"Warnings: ", resp.content)
|
||||
|
||||
self.check_equal(self.get("/api/repos/" + repo_name + "/packages").json(), ['Psource pyspi 0.6.1-1.3 3a8b37cbd9a3559e'])
|
||||
|
||||
@@ -169,10 +169,10 @@ class ReposAPITestAddFile(APITest):
|
||||
resp = self.get("/api/tasks/" + str(resp.json()['ID']) + "/output")
|
||||
self.check_equal(resp.status_code, 200)
|
||||
|
||||
self.check_in("Added: libboost-program-options-dev_1.49.0.1_i386 added", resp.content)
|
||||
self.check_equal("Removed: " in resp.content, False)
|
||||
self.check_equal("Failed files: " in resp.content, False)
|
||||
self.check_equal("Warnings: " in resp.content, False)
|
||||
self.check_in(b"Added: libboost-program-options-dev_1.49.0.1_i386 added", resp.content)
|
||||
self.check_not_in(b"Removed: ", resp.content)
|
||||
self.check_not_in(b"Failed files: ", resp.content)
|
||||
self.check_not_in(b"Warnings: ", resp.content)
|
||||
|
||||
self.check_equal(self.get("/api/repos/" + repo_name + "/packages").json(),
|
||||
['Pi386 libboost-program-options-dev 1.49.0.1 918d2f433384e378'])
|
||||
@@ -200,10 +200,10 @@ class ReposAPITestInclude(APITest):
|
||||
|
||||
resp = self.get("/api/tasks/" + str(resp.json()['ID']) + "/output")
|
||||
self.check_equal(resp.status_code, 200)
|
||||
self.check_in("Added: hardlink_0.2.1_source added, hardlink_0.2.1_amd64 added", resp.content)
|
||||
self.check_in(b"Added: hardlink_0.2.1_source added, hardlink_0.2.1_amd64 added", resp.content)
|
||||
self.check_equal(
|
||||
sorted(self.get("/api/repos/" + repo_name + "/packages").json()),
|
||||
[u'Pamd64 hardlink 0.2.1 daf8fcecbf8210ad', u'Psource hardlink 0.2.1 8f72df429d7166e5']
|
||||
['Pamd64 hardlink 0.2.1 daf8fcecbf8210ad', 'Psource hardlink 0.2.1 8f72df429d7166e5']
|
||||
)
|
||||
|
||||
self.check_not_exists("upload/" + d)
|
||||
@@ -238,7 +238,7 @@ class ReposAPITestShowQuery(APITest):
|
||||
|
||||
resp = self.get("/api/repos/" + repo_name + "/packages", params={"q": "pyspi)"})
|
||||
self.check_equal(resp.status_code, 400)
|
||||
self.check_equal(resp.json()["error"], u'parsing failed: unexpected token ): expecting end of query')
|
||||
self.check_equal(resp.json()["error"], 'parsing failed: unexpected token ): expecting end of query')
|
||||
|
||||
|
||||
class ReposAPITestAddMultiple(APITest):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from api_lib import APITest
|
||||
from publish import DefaultSigningOptions
|
||||
from .publish import DefaultSigningOptions
|
||||
|
||||
|
||||
class SnapshotsAPITestCreateShowEmpty(APITest):
|
||||
@@ -8,8 +8,8 @@ class SnapshotsAPITestCreateShowEmpty(APITest):
|
||||
"""
|
||||
def check(self):
|
||||
snapshot_name = self.random_name()
|
||||
snapshot_desc = {u'Description': u'fun snapshot',
|
||||
u'Name': snapshot_name}
|
||||
snapshot_desc = {'Description': 'fun snapshot',
|
||||
'Name': snapshot_name}
|
||||
|
||||
# create empty snapshot
|
||||
resp = self.post_task("/api/snapshots", json=snapshot_desc)
|
||||
@@ -36,9 +36,9 @@ class SnapshotsAPITestCreateFromRefs(APITest):
|
||||
"""
|
||||
def check(self):
|
||||
snapshot_name = self.random_name()
|
||||
snapshot_desc = {u'Description': u'fun snapshot',
|
||||
u'Name': snapshot_name,
|
||||
u'SourceSnapshots': [self.random_name()]}
|
||||
snapshot_desc = {'Description': 'fun snapshot',
|
||||
'Name': snapshot_name,
|
||||
'SourceSnapshots': [self.random_name()]}
|
||||
|
||||
# creating snapshot from missing source snapshot
|
||||
resp = self.post("/api/snapshots", json=snapshot_desc)
|
||||
@@ -115,15 +115,15 @@ class SnapshotsAPITestCreateFromRepo(APITest):
|
||||
self.check_equal(resp.json()['State'], 2)
|
||||
self.check_equal(self.get("/api/snapshots/" + snapshot_name).status_code, 200)
|
||||
|
||||
self.check_subset({u'Architecture': 'i386',
|
||||
u'Package': 'libboost-program-options-dev',
|
||||
u'Version': '1.49.0.1',
|
||||
self.check_subset({'Architecture': 'i386',
|
||||
'Package': 'libboost-program-options-dev',
|
||||
'Version': '1.49.0.1',
|
||||
'FilesHash': '918d2f433384e378'},
|
||||
self.get("/api/snapshots/" + snapshot_name + "/packages", params={"format": "details"}).json()[0])
|
||||
|
||||
self.check_subset({u'Architecture': 'i386',
|
||||
u'Package': 'libboost-program-options-dev',
|
||||
u'Version': '1.49.0.1',
|
||||
self.check_subset({'Architecture': 'i386',
|
||||
'Package': 'libboost-program-options-dev',
|
||||
'Version': '1.49.0.1',
|
||||
'FilesHash': '918d2f433384e378'},
|
||||
self.get("/api/snapshots/" + snapshot_name + "/packages",
|
||||
params={"format": "details", "q": "Version (> 0.6.1-1.4)"}).json()[0])
|
||||
@@ -139,8 +139,8 @@ class SnapshotsAPITestCreateUpdate(APITest):
|
||||
"""
|
||||
def check(self):
|
||||
snapshot_name = self.random_name()
|
||||
snapshot_desc = {u'Description': u'fun snapshot',
|
||||
u'Name': snapshot_name}
|
||||
snapshot_desc = {'Description': 'fun snapshot',
|
||||
'Name': snapshot_name}
|
||||
|
||||
resp = self.post_task("/api/snapshots", json=snapshot_desc)
|
||||
self.check_equal(resp.json()['State'], 2)
|
||||
@@ -171,8 +171,8 @@ class SnapshotsAPITestCreateDelete(APITest):
|
||||
"""
|
||||
def check(self):
|
||||
snapshot_name = self.random_name()
|
||||
snapshot_desc = {u'Description': u'fun snapshot',
|
||||
u'Name': snapshot_name}
|
||||
snapshot_desc = {'Description': 'fun snapshot',
|
||||
'Name': snapshot_name}
|
||||
|
||||
# deleting unreferenced snapshot
|
||||
resp = self.post_task("/api/snapshots", json=snapshot_desc)
|
||||
@@ -251,8 +251,8 @@ class SnapshotsAPITestDiff(APITest):
|
||||
GET /api/snapshot/:name/diff/:name2
|
||||
"""
|
||||
def check(self):
|
||||
repos = [self.random_name() for x in xrange(2)]
|
||||
snapshots = [self.random_name() for x in xrange(2)]
|
||||
repos = [self.random_name() for x in range(2)]
|
||||
snapshots = [self.random_name() for x in range(2)]
|
||||
|
||||
for repo_name in repos:
|
||||
self.check_equal(self.post("/api/repos", json={"Name": repo_name}).status_code, 201)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import requests_unixsocket
|
||||
import urllib
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import os
|
||||
import os.path
|
||||
|
||||
@@ -42,5 +44,5 @@ class SystemdAPIHandoverTest(BaseTest):
|
||||
print("Skipping test as we failed to setup a listener.")
|
||||
return
|
||||
session = requests_unixsocket.Session()
|
||||
r = session.get('http+unix://%s/api/version' % urllib.quote(self.socket_path, safe=''))
|
||||
r = session.get('http+unix://%s/api/version' % urllib.parse.quote(self.socket_path, safe=''))
|
||||
self.check_equal(r.json(), {'Version': os.environ['APTLY_VERSION']})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from api_lib import APITest
|
||||
from publish import DefaultSigningOptions
|
||||
from .publish import DefaultSigningOptions
|
||||
|
||||
|
||||
class TaskAPITestParallelTasks(APITest):
|
||||
@@ -8,11 +8,11 @@ class TaskAPITestParallelTasks(APITest):
|
||||
"""
|
||||
def _create_mirror(self, dist):
|
||||
mirror_name = self.random_name()
|
||||
mirror_desc = {u'Name': mirror_name,
|
||||
u'ArchiveURL': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
u'Distribution': dist,
|
||||
u'Components': ['main']}
|
||||
mirror_desc[u'IgnoreSignatures'] = True
|
||||
mirror_desc = {'Name': mirror_name,
|
||||
'ArchiveURL': 'https://packagecloud.io/varnishcache/varnish30/debian/',
|
||||
'Distribution': dist,
|
||||
'Components': ['main']}
|
||||
mirror_desc['IgnoreSignatures'] = True
|
||||
resp = self.post("/api/mirrors", json=mirror_desc)
|
||||
self.check_equal(resp.status_code, 201)
|
||||
resp = self.put("/api/mirrors/" + mirror_name, json=mirror_desc, params={'_async': True})
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import requests_unixsocket
|
||||
import time
|
||||
import os
|
||||
import urllib
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from lib import BaseTest
|
||||
|
||||
@@ -32,7 +34,7 @@ class UnixSocketAPITest(BaseTest):
|
||||
"""
|
||||
def check(self):
|
||||
session = requests_unixsocket.Session()
|
||||
r = session.get('http+unix://%s/api/version' % urllib.quote(UnixSocketAPITest.socket_path, safe=''))
|
||||
r = session.get('http+unix://%s/api/version' % urllib.parse.quote(UnixSocketAPITest.socket_path, safe=''))
|
||||
# Just needs to come back, we actually don't care much about the code.
|
||||
# Only needs to verify that the socket is actually responding.
|
||||
self.check_equal(r.json(), {'Version': os.environ['APTLY_VERSION']})
|
||||
|
||||
Reference in New Issue
Block a user