mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-04 05:10:40 +00:00
Basic test of graph layout
This commit is contained in:
@@ -270,6 +270,14 @@ class BaseTest(object):
|
||||
if a != b:
|
||||
self.verify_match(a, b, match_prepare=pprint.pformat)
|
||||
|
||||
def check_ge(self, a, b):
|
||||
if not a >= b:
|
||||
raise Exception("%s is not greater or equal to %s" % (a, b))
|
||||
|
||||
def check_gt(self, a, b):
|
||||
if not a > b:
|
||||
raise Exception("%s is not greater to %s" % (a, b))
|
||||
|
||||
def check_in(self, item, l):
|
||||
if not item in l:
|
||||
raise Exception("item %r not in %r", item, l)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from api_lib import APITest
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
class GraphAPITest(APITest):
|
||||
@@ -15,3 +16,20 @@ class GraphAPITest(APITest):
|
||||
resp = self.get("/api/graph.svg")
|
||||
self.check_equal(resp.headers["Content-Type"], "image/svg+xml")
|
||||
self.check_equal(resp.content[:4], '<?xm')
|
||||
|
||||
# make sure our default layout is horizontal
|
||||
default = self.get("/api/graph.svg").content
|
||||
horizontal = self.get("/api/graph.svg?layout=horizontal").content
|
||||
self.check_equal(default, horizontal)
|
||||
|
||||
# basic test of layout:
|
||||
# horizontal should be wider than vertical
|
||||
# vertical should be higher than horizontal
|
||||
vertical = self.get("/api/graph.svg?layout=vertical").content
|
||||
svgHWidth = ET.fromstring(horizontal).get('width').replace("pt","")
|
||||
svgHHeight = ET.fromstring(horizontal).get('height').replace("pt","")
|
||||
svgVWidth = ET.fromstring(vertical).get('width').replace("pt","")
|
||||
svgVHeight = ET.fromstring(vertical).get('height').replace("pt","")
|
||||
|
||||
self.check_gt(svgHWidth, svgVWidth)
|
||||
self.check_gt(svgVHeight, svgHHeight)
|
||||
|
||||
Reference in New Issue
Block a user