2014-02-26 16:23:16 +01:00
|
|
|
import os
|
|
|
|
import difflib
|
|
|
|
import subprocess
|
|
|
|
import tempfile
|
2014-02-28 11:45:06 +01:00
|
|
|
|
2014-03-07 15:10:04 +01:00
|
|
|
from osclib.freeze_command import FreezeCommand
|
2019-05-02 08:14:44 +02:00
|
|
|
from . import OBSLocal
|
2014-06-03 18:05:05 +02:00
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2019-05-02 08:14:44 +02:00
|
|
|
class TestFreeze(OBSLocal.TestCase):
|
2014-08-07 12:39:41 +02:00
|
|
|
|
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):
|
2021-08-25 12:13:56 +02:00
|
|
|
wf = OBSLocal.FactoryWorkflow()
|
2014-03-07 15:10:04 +01:00
|
|
|
|
2019-04-21 12:00:26 +02:00
|
|
|
fc = FreezeCommand(wf.api)
|
2014-02-26 16:23:16 +01:00
|
|
|
|
|
|
|
fp = self._get_fixture_path('staging-meta-for-bootstrap-copy.xml')
|
2022-04-01 10:25:02 +02:00
|
|
|
fc.prj = 'openSUSE:Factory:Staging:A'
|
2024-05-07 17:55:17 +02:00
|
|
|
fixture = subprocess.check_output(f'/usr/bin/xmllint --format {fp}', shell=True).decode('utf-8')
|
2014-02-26 16:23:16 +01:00
|
|
|
|
|
|
|
f = tempfile.NamedTemporaryFile(delete=False)
|
2022-04-01 10:25:02 +02:00
|
|
|
f.write(fc.prj_meta_for_bootstrap_copy())
|
2014-02-26 16:23:16 +01:00
|
|
|
f.close()
|
|
|
|
|
2024-05-07 17:55:17 +02:00
|
|
|
output = subprocess.check_output(f'/usr/bin/xmllint --format {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)
|