From f405aedf6e9ab1fbd739a7c296242355cde18a16 Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Thu, 5 Oct 2017 14:57:46 +0300 Subject: [PATCH] Add first unit test so we can start collecting coverage --- tests/pylorax/test_buildstamp.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/pylorax/test_buildstamp.py diff --git a/tests/pylorax/test_buildstamp.py b/tests/pylorax/test_buildstamp.py new file mode 100644 index 00000000..b33d5fad --- /dev/null +++ b/tests/pylorax/test_buildstamp.py @@ -0,0 +1,23 @@ +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' + ) + + 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", out_file.getvalue()) + self.assertIn("[Compose]\nLorax=devel", out_file.getvalue())