Skip to content

Commit

Permalink
Tests: Add Basic test for graph command
Browse files Browse the repository at this point in the history
  • Loading branch information
reglim committed Dec 13, 2023
1 parent faa3935 commit 486e864
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions system/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ def check_exists(self, path):
if not os.path.exists(os.path.join(os.environ["HOME"], self.aptlyDir, path)):
raise Exception("path %s doesn't exist" % (path, ))

def check_exists_in_cwd(self, path):
if not os.path.exists(path):
raise Exception(f"path {path} doesn't exist")

def check_not_exists(self, path):
if os.path.exists(os.path.join(os.environ["HOME"], self.aptlyDir, path)):
raise Exception("path %s exists" % (path, ))
Expand Down
1 change: 1 addition & 0 deletions system/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ requests-unixsocket
python-swiftclient
flake8
termcolor
pillow
3 changes: 3 additions & 0 deletions system/t13_graph/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Testing Aptly Graph Command
"""
25 changes: 25 additions & 0 deletions system/t13_graph/graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from PIL import Image
from lib import BaseTest


class GraphTest1(BaseTest):
"""
Test that graph is generated correctly and accessible at the specified output path.
"""

fixtureDB = True
fixturePool = True
fixtureCmds = [
"aptly snapshot create snap1 from mirror gnuplot-maverick",
"aptly publish snapshot -skip-signing snap1",
]
runCmd = "aptly graph -output=graph.png -layout=horizontal"

def check(self):
self.check_exists_in_cwd("graph.png")

with Image.open("graph.png") as img:
(width, height) = img.size
# check is horizontal
self.check_gt(width, height)
img.verify()

0 comments on commit 486e864

Please sign in to comment.