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:
parent
dd2446faf6
commit
a30afe6e5c
@ -21,5 +21,5 @@ class BuildStampTestCase(unittest.TestCase):
|
|||||||
with patch.object(buildstamp, 'open', return_value=out_file):
|
with patch.object(buildstamp, 'open', return_value=out_file):
|
||||||
self.bstamp.write('/tmp/stamp.ini')
|
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())
|
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
|
# Skip UUID which is between IsFinal and Variant, and specific version which will change
|
||||||
self.assertIn("Variant=Server\n[Compose]\nLorax=devel", out_file.getvalue())
|
self.assertIn("Variant=Server\n[Compose]\nLorax=", out_file.getvalue())
|
||||||
|
@ -72,6 +72,18 @@ def get_system_repo():
|
|||||||
# Failed to find one, fall back to using base
|
# Failed to find one, fall back to using base
|
||||||
return "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):
|
class ServerTestCase(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(self):
|
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"Lorax [\d.]+ documentation")
|
||||||
self.assertRegex(response.data.decode("utf-8"), r"Copyright \d+, Red Hat, Inc.")
|
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):
|
def test_api_docs(self):
|
||||||
"""Test the /api/docs/"""
|
"""Test the /api/docs/"""
|
||||||
resp = self.server.get("/api/docs/")
|
resp = self.server.get("/api/docs/")
|
||||||
self.assert_documentation(resp)
|
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):
|
def test_api_docs_with_existing_path(self):
|
||||||
"""Test the /api/docs/modules.html"""
|
"""Test the /api/docs/modules.html"""
|
||||||
resp = self.server.get("/api/docs/modules.html")
|
resp = self.server.get("/api/docs/modules.html")
|
||||||
|
Loading…
Reference in New Issue
Block a user