Esempio n. 1
0
 def test_route_args(self, stderr):
     parsed = plugin.get_route_args(
         ['add', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out', '-d', 'destination.host'])
     self.assertEqual(parsed.action, 'add')
     self.assertEqual(parsed.path, '/path/out')
     self.assertEqual(parsed.destination, 'destination.host')
     parsed = plugin.get_route_args(
         ['add', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out', '-c', 'my content'])
     self.assertEqual(parsed.action, 'add')
     self.assertEqual(parsed.path, '/path/out')
     self.assertEqual(parsed.content, 'my content')
     parsed = plugin.get_route_args(['remove', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out'])
     self.assertEqual(parsed.action, 'remove')
     self.assertEqual(parsed.path, '/path/out')
     with self.assertRaises(SystemExit) as cm:
         plugin.get_route_args(['add', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out'])
     exc = cm.exception
     self.assertEqual(2, exc.code)
     stderr.write.assert_called_with('destination xor content are required to add action\n')
     with self.assertRaises(SystemExit) as cm:
         plugin.get_route_args([
             'add', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out',
             '-d', 'destination.host', '-c', 'my content',
         ])
     exc = cm.exception
     self.assertEqual(3, exc.code)
     stderr.write.assert_called_with('cannot have both destination and content\n')
     with self.assertRaises(SystemExit) as cm:
         plugin.get_route_args(['-s', 'myservice', '-i', 'myinst', '-p', '/path/out'])
     exc = cm.exception
     self.assertEqual(2, exc.code)
     stderr.write.assert_called_with('route: error: too few arguments\n')
Esempio n. 2
0
 def test_route_args(self, stderr):
     parsed = plugin.get_route_args(
         ['add', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out', '-d', 'destination.host'])
     self.assertEqual(parsed.action, 'add')
     self.assertEqual(parsed.path, '/path/out')
     self.assertEqual(parsed.destination, 'destination.host')
     parsed = plugin.get_route_args(
         ['add', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out', '-c', 'my content'])
     self.assertEqual(parsed.action, 'add')
     self.assertEqual(parsed.path, '/path/out')
     self.assertEqual(parsed.content, 'my content')
     parsed = plugin.get_route_args(['remove', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out'])
     self.assertEqual(parsed.action, 'remove')
     self.assertEqual(parsed.path, '/path/out')
     with self.assertRaises(SystemExit) as cm:
         plugin.get_route_args(['add', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out'])
     exc = cm.exception
     self.assertEqual(2, exc.code)
     stderr.write.assert_called_with('destination xor content are required to add action\n')
     with self.assertRaises(SystemExit) as cm:
         plugin.get_route_args([
             'add', '-s', 'myservice', '-i', 'myinst', '-p', '/path/out',
             '-d', 'destination.host', '-c', 'my content',
         ])
     exc = cm.exception
     self.assertEqual(3, exc.code)
     stderr.write.assert_called_with('cannot have both destination and content\n')
     with self.assertRaises(SystemExit) as cm:
         plugin.get_route_args(['-s', 'myservice', '-i', 'myinst', '-p', '/path/out'])
     exc = cm.exception
     self.assertEqual(2, exc.code)
     stderr.write.assert_called_with('route: error: too few arguments\n')