openSUSE-release-tools/tests/freeze_tests.py

42 lines
1.2 KiB
Python
Raw Normal View History

2014-02-26 16:23:16 +01:00
import os
import difflib
import subprocess
import tempfile
2014-02-28 11:45:06 +01:00
from osclib.freeze_command import FreezeCommand
from . import OBSLocal
class TestFreeze(OBSLocal.TestCase):
2014-02-26 16:23:16 +01:00
def _get_fixture_path(self, filename):
"""
Return path for fixture
"""
return os.path.join(self._get_fixtures_dir(), filename)
def _get_fixtures_dir(self):
"""
Return path for fixtures
"""
return os.path.join(os.getcwd(), 'tests/fixtures')
def test_bootstrap_copy(self):
wf = OBSLocal.FactoryWorkflow()
fc = FreezeCommand(wf.api)
2014-02-26 16:23:16 +01:00
fp = self._get_fixture_path('staging-meta-for-bootstrap-copy.xml')
fc.prj = 'openSUSE:Factory:Staging:A'
2019-05-02 20:34:21 +02:00
fixture = subprocess.check_output('/usr/bin/xmllint --format %s' % fp, shell=True).decode('utf-8')
2014-02-26 16:23:16 +01:00
f = tempfile.NamedTemporaryFile(delete=False)
f.write(fc.prj_meta_for_bootstrap_copy())
2014-02-26 16:23:16 +01:00
f.close()
2019-05-02 20:34:21 +02:00
output = subprocess.check_output('/usr/bin/xmllint --format %s' % f.name, shell=True).decode('utf-8')
2014-02-26 16:23:16 +01:00
for line in difflib.unified_diff(fixture.split("\n"), output.split("\n")):
print(line)
self.assertEqual(output, fixture)