Exemple #1
0
 def test_lua_args(self, stderr):
     parsed = plugin.get_lua_args(
         ['add', '-s', 'myservice', '-i', 'myinst', '-t', 'server', '-n', 'my_module', '-c', 'my lua'])
     self.assertEqual(parsed.action, 'add')
     self.assertEqual(parsed.type, 'server')
     self.assertEqual(parsed.module_name, 'my_module')
     self.assertEqual(parsed.content, 'my lua')
     with self.assertRaises(SystemExit) as cm:
         plugin.get_lua_args(['add', '-s', 'myservice', '-i', 'myinst', '-t', 'server'])
     exc = cm.exception
     self.assertEqual(2, exc.code)
     with self.assertRaises(SystemExit) as cm:
         plugin.get_lua_args([
             'add', '-s', 'myservice', '-i', 'myinst', '-t', 'worker', '-c', 'my content',
         ])
     exc = cm.exception
     self.assertEqual(2, exc.code)
     with self.assertRaises(SystemExit) as cm:
         plugin.get_lua_args(
             ['remove', '-s', 'myservice', '-i', 'myinst', '-t', 'xxx', '-n', 'lua_module']
         )
     exc = cm.exception
     self.assertEqual(2, exc.code)
     stderr.write.assert_called_with(
         'lua: error: argument -t/--type: Type must be "server" or "worker"\n'
     )
     with self.assertRaises(SystemExit) as cm:
         plugin.get_lua_args(
             ['-s', 'myservice', '-i', 'myinst', '-n', 'http']
         )
     exc = cm.exception
     self.assertEqual(2, exc.code)
     stderr.write.assert_called_with('lua: error: too few arguments\n')
Exemple #2
0
 def test_lua_args(self, stderr):
     parsed = plugin.get_lua_args(
         ['add', '-s', 'myservice', '-i', 'myinst', '-t', 'server', '-n', 'my_module', '-c', 'my lua'])
     self.assertEqual(parsed.action, 'add')
     self.assertEqual(parsed.type, 'server')
     self.assertEqual(parsed.module_name, 'my_module')
     self.assertEqual(parsed.content, 'my lua')
     with self.assertRaises(SystemExit) as cm:
         plugin.get_lua_args(['add', '-s', 'myservice', '-i', 'myinst', '-t', 'server'])
     exc = cm.exception
     self.assertEqual(2, exc.code)
     with self.assertRaises(SystemExit) as cm:
         plugin.get_lua_args([
             'add', '-s', 'myservice', '-i', 'myinst', '-t', 'worker', '-c', 'my content',
         ])
     exc = cm.exception
     self.assertEqual(2, exc.code)
     with self.assertRaises(SystemExit) as cm:
         plugin.get_lua_args(
             ['remove', '-s', 'myservice', '-i', 'myinst', '-t', 'xxx', '-n', 'lua_module']
         )
     exc = cm.exception
     self.assertEqual(2, exc.code)
     stderr.write.assert_called_with(
         'lua: error: argument -t/--type: Type must be "server" or "worker"\n'
     )
     with self.assertRaises(SystemExit) as cm:
         plugin.get_lua_args(
             ['-s', 'myservice', '-i', 'myinst', '-n', 'http']
         )
     exc = cm.exception
     self.assertEqual(2, exc.code)
     stderr.write.assert_called_with('lua: error: too few arguments\n')