2016-03-21 09:58:36 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import mock
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'bin'))
|
|
|
|
|
|
|
|
from tests import helpers
|
2016-04-05 07:13:01 +00:00
|
|
|
from pungi import ostree
|
2016-03-21 09:58:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OstreeScriptTest(helpers.PungiTestCase):
|
|
|
|
|
|
|
|
@mock.patch('kobo.shortcuts.run')
|
2016-04-07 12:33:37 +00:00
|
|
|
def test_full_run(self, run):
|
2016-04-05 07:13:01 +00:00
|
|
|
repo = os.path.join(self.topdir, 'atomic')
|
|
|
|
|
|
|
|
ostree.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--log-dir=%s' % os.path.join(self.topdir, 'logs', 'Atomic'),
|
|
|
|
'--treefile=%s/fedora-atomic-docker-host.json' % self.topdir,
|
2016-04-05 07:13:01 +00:00
|
|
|
repo,
|
2016-03-21 09:58:36 +00:00
|
|
|
])
|
2016-04-05 06:40:54 +00:00
|
|
|
|
2016-03-21 09:58:36 +00:00
|
|
|
self.maxDiff = None
|
|
|
|
self.assertItemsEqual(
|
|
|
|
run.call_args_list,
|
2016-05-25 11:37:39 +00:00
|
|
|
[mock.call(['ostree', 'init', '--repo=%s' % repo, '--mode=archive-z2'],
|
2016-04-08 09:17:49 +00:00
|
|
|
logfile=self.topdir + '/logs/Atomic/init-ostree-repo.log', show_cmd=True, stdout=True),
|
2016-05-25 11:37:39 +00:00
|
|
|
mock.call(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo,
|
2016-04-07 12:33:37 +00:00
|
|
|
self.topdir + '/fedora-atomic-docker-host.json'],
|
2016-04-08 09:17:49 +00:00
|
|
|
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log', show_cmd=True, stdout=True)])
|
2016-03-21 09:58:36 +00:00
|
|
|
|
2016-05-09 13:59:02 +00:00
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
|
|
def test_run_on_existing_empty_dir(self, run):
|
|
|
|
repo = os.path.join(self.topdir, 'atomic')
|
|
|
|
|
|
|
|
os.mkdir(repo)
|
|
|
|
|
|
|
|
ostree.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--log-dir=%s' % os.path.join(self.topdir, 'logs', 'Atomic'),
|
|
|
|
'--treefile=%s/fedora-atomic-docker-host.json' % self.topdir,
|
2016-05-09 13:59:02 +00:00
|
|
|
repo,
|
|
|
|
])
|
|
|
|
|
|
|
|
self.maxDiff = None
|
|
|
|
self.assertItemsEqual(
|
|
|
|
run.call_args_list,
|
2016-05-25 11:37:39 +00:00
|
|
|
[mock.call(['ostree', 'init', '--repo=%s' % repo, '--mode=archive-z2'],
|
2016-05-09 13:59:02 +00:00
|
|
|
logfile=self.topdir + '/logs/Atomic/init-ostree-repo.log', show_cmd=True, stdout=True),
|
2016-05-25 11:37:39 +00:00
|
|
|
mock.call(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo,
|
2016-05-09 13:59:02 +00:00
|
|
|
self.topdir + '/fedora-atomic-docker-host.json'],
|
|
|
|
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log', show_cmd=True, stdout=True)])
|
|
|
|
|
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
|
|
def test_run_on_initialized_repo(self, run):
|
|
|
|
repo = os.path.join(self.topdir, 'atomic')
|
|
|
|
|
|
|
|
helpers.touch(os.path.join(repo, 'initialized'))
|
|
|
|
|
|
|
|
ostree.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--log-dir=%s' % os.path.join(self.topdir, 'logs', 'Atomic'),
|
|
|
|
'--treefile=%s/fedora-atomic-docker-host.json' % self.topdir,
|
2016-05-09 13:59:02 +00:00
|
|
|
repo,
|
|
|
|
])
|
|
|
|
|
|
|
|
self.maxDiff = None
|
|
|
|
self.assertItemsEqual(
|
|
|
|
run.call_args_list,
|
2016-05-25 11:37:39 +00:00
|
|
|
[mock.call(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo,
|
2016-05-09 13:59:02 +00:00
|
|
|
self.topdir + '/fedora-atomic-docker-host.json'],
|
|
|
|
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log', show_cmd=True, stdout=True)])
|
|
|
|
|
2016-03-21 09:58:36 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|