IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Browse Source

Add test_command_image_list().

master
parent
commit
db175c877a
1 changed files with 30 additions and 1 deletions
  1. +30
    -1
      tests/test_image.py

+ 30
- 1
tests/test_image.py View File

@@ -4,7 +4,8 @@ from focker.image import validate_spec, \
build, \
command_image_build, \
command_image_tag, \
command_image_untag
command_image_untag, \
command_image_list
import subprocess
from tempfile import TemporaryDirectory
import focker.image
@@ -162,3 +163,31 @@ def test_command_image_untag():
with pytest.raises(ValueError):
zfs_find('test-command-image-untag-2', focker_type='image')
subprocess.check_output(['focker', 'image', 'remove', 'test-command-image-untag'])
def test_command_image_list(monkeypatch):
focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-command-image-list'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-command-image-list', 'test-command-image-list-1', 'test-command-image-list-2'])
name, sha256 = zfs_find('test-command-image-list', focker_type='image')
args = lambda: 0
args.tagged_only = True
args.full_sha256 = True
lst = None
headers = None
def fake_tabulate(*args, **kwargs):
nonlocal lst
nonlocal headers
lst = args[0]
headers = kwargs['headers']
monkeypatch.setattr(focker.image, 'tabulate', fake_tabulate)
command_image_list(args)
assert lst is not None
assert headers == ['Tags', 'Size', 'SHA256', 'Base']
assert len(lst) >= 3
match = list(filter(lambda a: sorted(a[0].split(' ')) == ['test-command-image-list', 'test-command-image-list-1', 'test-command-image-list-2'], lst))
assert len(match) == 1
match = match[0]
assert match[2] == sha256
assert match[3] == '-'
subprocess.check_output(['focker', 'image', 'remove', 'test-command-image-list'])

Loading…
Cancel
Save