Commit 21cac5da authored by Jérome Perrin's avatar Jérome Perrin

test: check that unreachable schema issue a warning

parent c434c04b
...@@ -32,6 +32,7 @@ import shutil ...@@ -32,6 +32,7 @@ import shutil
import tempfile import tempfile
import textwrap import textwrap
import unittest import unittest
import warnings
from pwd import getpwnam from pwd import getpwnam
from six.moves import SimpleHTTPServer from six.moves import SimpleHTTPServer
...@@ -458,11 +459,19 @@ class TestSoftwareReleaseSchemaEdgeCases(unittest.TestCase): ...@@ -458,11 +459,19 @@ class TestSoftwareReleaseSchemaEdgeCases(unittest.TestCase):
def test_software_schema_file_not_exist(self): def test_software_schema_file_not_exist(self):
schema = SoftwareReleaseSchema('/file/not/exist', None) schema = SoftwareReleaseSchema('/file/not/exist', None)
self.assertIsNone(schema.getSoftwareSchema()) with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
self.assertIsNone(schema.getSoftwareSchema())
self.assertEqual(len(w), 1)
self.assertIn("Unable to load JSON", str(w[0].message))
def test_software_schema_wrong_URL(self): def test_software_schema_wrong_URL(self):
schema = SoftwareReleaseSchema('http://slapos.invalid/software.cfg', None) schema = SoftwareReleaseSchema('http://slapos.invalid/software.cfg', None)
self.assertIsNone(schema.getSoftwareSchema()) with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
self.assertIsNone(schema.getSoftwareSchema())
self.assertEqual(len(w), 1)
self.assertIn("Unable to load JSON", str(w[0].message))
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment