openSUSE-release-tools/tests/freeze_tests.py

51 lines
1.4 KiB
Python
Raw Normal View History

2014-02-26 16:23:16 +01:00
import os
import unittest
import difflib
import subprocess
import tempfile
2014-02-28 11:45:06 +01:00
from . import obs
from osclib.conf import Config
from osclib.freeze_command import FreezeCommand
from osclib.stagingapi import StagingAPI
2014-02-26 16:23:16 +01:00
2014-02-26 16:23:16 +01:00
class TestFreeze(unittest.TestCase):
def setUp(self):
"""
Initialize the configuration
"""
self.obs = obs.OBS()
Config(obs.APIURL, 'openSUSE:Factory')
self.api = StagingAPI(obs.APIURL, 'openSUSE:Factory')
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):
fc = FreezeCommand(self.api)
2014-02-26 16:23:16 +01:00
fp = self._get_fixture_path('staging-meta-for-bootstrap-copy.xml')
fixture = subprocess.check_output('/usr/bin/xmllint --format %s' % fp, shell=True)
f = tempfile.NamedTemporaryFile(delete=False)
f.write(fc.prj_meta_for_bootstrap_copy('openSUSE:Factory:Staging:A'))
f.close()
output = subprocess.check_output('/usr/bin/xmllint --format %s' % f.name, shell=True)
for line in difflib.unified_diff(fixture.split("\n"), output.split("\n")):
print(line)
self.assertEqual(output, fixture)