Tests: assertTry() function introduced.
This commit is contained in:
@@ -6,12 +6,36 @@ class TestUnitConfiguration(unit.TestUnitControl):
|
|||||||
def setUpClass():
|
def setUpClass():
|
||||||
unit.TestUnit().check_modules('python')
|
unit.TestUnit().check_modules('python')
|
||||||
|
|
||||||
|
def test_json(self):
|
||||||
|
self.assertIn('error', self.put('/', '00'), 'leading zero')
|
||||||
|
|
||||||
def test_json_applications(self):
|
def test_json_applications(self):
|
||||||
self.assertIn('error', self.put('/applications', '"{}"'),
|
self.assertIn('error', self.put('/applications', '"{}"'),
|
||||||
'applications string')
|
'applications string')
|
||||||
self.assertIn('error', self.put('/applications', '{'),
|
self.assertIn('error', self.put('/applications', '{'),
|
||||||
'applications miss brace')
|
'applications miss brace')
|
||||||
|
|
||||||
|
self.assertTry('assertIn', 'negative workers', 'error',
|
||||||
|
self.put('/applications', """
|
||||||
|
{
|
||||||
|
"app": {
|
||||||
|
"type": "python",
|
||||||
|
"workers": -1,
|
||||||
|
"path": "/app",
|
||||||
|
"module": "wsgi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""))
|
||||||
|
|
||||||
|
self.assertTry('assertIn', 'application type only', 'error',
|
||||||
|
self.put('/applications', """
|
||||||
|
{
|
||||||
|
"app": {
|
||||||
|
"type": "python"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""))
|
||||||
|
|
||||||
self.assertIn('error', self.put('/applications', """
|
self.assertIn('error', self.put('/applications', """
|
||||||
{
|
{
|
||||||
app": {
|
app": {
|
||||||
@@ -93,6 +117,8 @@ class TestUnitConfiguration(unit.TestUnitControl):
|
|||||||
"""), 'unicode number')
|
"""), 'unicode number')
|
||||||
|
|
||||||
def test_json_listeners(self):
|
def test_json_listeners(self):
|
||||||
|
self.assertTry('assertIn', 'listener empty', 'error',
|
||||||
|
self.put('/listeners', '{"*:7080":{}}'))
|
||||||
self.assertIn('error', self.put('/listeners',
|
self.assertIn('error', self.put('/listeners',
|
||||||
'{"*:7080":{"application":"app"}}'), 'listeners no app')
|
'{"*:7080":{"application":"app"}}'), 'listeners no app')
|
||||||
|
|
||||||
@@ -116,24 +142,5 @@ class TestUnitConfiguration(unit.TestUnitControl):
|
|||||||
self.assertIn('error', self.put('/listeners',
|
self.assertIn('error', self.put('/listeners',
|
||||||
'{"127.0.0.1":{"application":"app"}}'), 'listeners no port')
|
'{"127.0.0.1":{"application":"app"}}'), 'listeners no port')
|
||||||
|
|
||||||
@unittest.skip("TODO")
|
|
||||||
def test_broken(self):
|
|
||||||
self.assertIn('error', self.put('/', '00'), 'leading zero')
|
|
||||||
self.assertIn('error', self.put('/listeners', '{"*:7080":{}}'),
|
|
||||||
'listener empty')
|
|
||||||
self.assertIn('error', self.put('/applications', '"type":"python"'),
|
|
||||||
'application type only')
|
|
||||||
|
|
||||||
self.assertIn('error', self.put('/applications', """
|
|
||||||
{
|
|
||||||
"app": {
|
|
||||||
"type": "python",
|
|
||||||
"workers": -1,
|
|
||||||
"path": "/app",
|
|
||||||
"module": "wsgi"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"""), 'negative workers')
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ class TestUnit(unittest.TestCase):
|
|||||||
if '--leave' not in sys.argv:
|
if '--leave' not in sys.argv:
|
||||||
shutil.rmtree(self.testdir)
|
shutil.rmtree(self.testdir)
|
||||||
|
|
||||||
|
def assertTry(self, assert_method, description, *args):
|
||||||
|
try: getattr(self, assert_method)(*args, description)
|
||||||
|
except AssertionError: print('not yet: ' + description)
|
||||||
|
|
||||||
def check_modules(self, *modules):
|
def check_modules(self, *modules):
|
||||||
self._run()
|
self._run()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user