def test_change_permissions(self):
     """fileops:ChangePermissions with params parses correctly"""
     expected = ['chmod 0644 /tmp/file']
     params = {
         'hosts': ['testhost.example.com'],
         'command': 'fileops',
         'subcommand': 'ChangePermissions',
         'path': '/tmp/file',
         'mode': '0644'
     }
     (update, cmd) = fileops._parse_ChangePermissions(params, self.app_logger)
     self.assertEqual(cmd, expected)
    def test_change_permissions_error_conditions(self):
        """fileops:ChangePermissions verify error conditions"""

        # Missing "path"
        params = {
            'hosts': ['testhost.example.com'],
            'command': 'fileops',
            'subcommand': 'ChangePermissions',
            'mode': '0644',
        }

        with self.assertRaises(TypeError):
            fileops._parse_ChangePermissions(params, self.app_logger)

        # Missing "mode"
        params = {
            'hosts': ['testhost.example.com'],
            'command': 'fileops',
            'subcommand': 'ChangePermissions',
            'path': '/a/path/to/file',
        }

        with self.assertRaises(TypeError):
            fileops._parse_ChangeOwnership(params, self.app_logger)