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
This commit is contained in:
Brian C. Lane 2019-04-03 16:34:33 -07:00
parent dd2446faf6
commit a30afe6e5c
2 changed files with 16 additions and 2 deletions

View File

@ -21,5 +21,5 @@ class BuildStampTestCase(unittest.TestCase):
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
self.assertIn("Variant=Server\n[Compose]\nLorax=devel", 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())

View File

@ -72,6 +72,18 @@ def get_system_repo():
# Failed to find one, fall back to using base
return "base"
def docs_path():
"""Helper that points to where documentation should be.
They may not be installed, so in that case the doc test should be skipped
"""
try:
return os.path.abspath(joinpaths(os.path.dirname(__file__), "../../../docs/html"))
except IndexError:
return "/usr/share/doc/lorax/html"
class ServerTestCase(unittest.TestCase):
@classmethod
def setUpClass(self):
@ -804,11 +816,13 @@ class ServerTestCase(unittest.TestCase):
self.assertRegex(response.data.decode("utf-8"), r"Lorax [\d.]+ documentation")
self.assertRegex(response.data.decode("utf-8"), r"Copyright \d+, Red Hat, Inc.")
@unittest.skipUnless(os.path.exists(docs_path()), "Test requires a running API server")
def test_api_docs(self):
"""Test the /api/docs/"""
resp = self.server.get("/api/docs/")
self.assert_documentation(resp)
@unittest.skipUnless(os.path.exists(docs_path()), "Test requires a running API server")
def test_api_docs_with_existing_path(self):
"""Test the /api/docs/modules.html"""
resp = self.server.get("/api/docs/modules.html")