lorax/tests/pylorax/test_buildstamp.py
Brian C. Lane a30afe6e5c tests: Skip docs if not installed
And make buildstamp test ignore the version number, since it might be
devel or it might be an actual version when running against the
installed package.

Related: rhbz#1678937
2019-04-05 11:05:58 -07:00

26 lines
1002 B
Python

import io
import unittest
from unittest.mock import patch
from pylorax import buildstamp
class BuildStampTestCase(unittest.TestCase):
def setUp(self):
self.bstamp = buildstamp.BuildStamp(
'Lorax Tests',
'0.1',
'https://github.com/rhinstaller/lorax/issues',
True,
'noarch',
'Server'
)
def test_write_produces_file_with_expected_content(self):
out_file = io.StringIO()
with patch.object(out_file, 'close'):
with patch.object(buildstamp, 'open', return_value=out_file):
self.bstamp.write('/tmp/stamp.ini')
self.assertIn("[Main]\nProduct=Lorax Tests\nVersion=0.1\nBugURL=https://github.com/rhinstaller/lorax/issues\nIsFinal=True\n", out_file.getvalue())
# Skip UUID which is between IsFinal and Variant, and specific version which will change
self.assertIn("Variant=Server\n[Compose]\nLorax=", out_file.getvalue())