forked from openSUSE/openSUSE-release-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
freeze_tests.py
41 lines (30 loc) · 1.18 KB
/
freeze_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import difflib
import subprocess
import tempfile
from osclib.freeze_command import FreezeCommand
from . import OBSLocal
class TestFreeze(OBSLocal.TestCase):
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)
fp = self._get_fixture_path('staging-meta-for-bootstrap-copy.xml')
fc.prj = 'openSUSE:Factory:Staging:A'
fixture = subprocess.check_output('/usr/bin/xmllint --format %s' % fp, shell=True).decode('utf-8')
f = tempfile.NamedTemporaryFile(delete=False)
f.write(fc.prj_meta_for_bootstrap_copy())
f.close()
output = subprocess.check_output('/usr/bin/xmllint --format %s' % f.name, shell=True).decode('utf-8')
for line in difflib.unified_diff(fixture.split("\n"), output.split("\n")):
print(line)
self.assertEqual(output, fixture)