def testFolderMetadataCrud(self):
        # Grab the default user folders
        resp = self.request(
            path='/folder', method='GET', user=self.admin, params={
                'parentType': 'user',
                'parentId': self.admin['_id'],
                'sort': 'name',
                'sortdir': 1
            })
        self.assertStatusOk(resp)
        publicFolder = resp.json[1]

        # Actually create subfolder under Public
        resp = self.request(
            path='/folder', method='POST', user=self.admin, params={
                'name': ' My public subfolder  ',
                'parentId': publicFolder['_id']
            })
        self.assertStatusOk(resp)
        folder = resp.json

        # Test that bad json fails
        resp = self.request(path='/folder/%s/metadata' % folder['_id'],
                            method='PUT', user=self.admin,
                            body='badJSON', type='application/json')
        self.assertStatus(resp, 400)

        # Add some metadata
        metadata = {
            'foo': 'bar',
            'test': 2
        }
        resp = self.request(path='/folder/%s/metadata' % folder['_id'],
                            method='PUT', user=self.admin,
                            body=json.dumps(metadata), type='application/json')

        folder = resp.json
        self.assertEqual(folder['meta']['foo'], metadata['foo'])
        self.assertEqual(folder['meta']['test'], metadata['test'])

        # Edit and remove metadata
        metadata['test'] = None
        metadata['foo'] = 'baz'
        resp = self.request(path='/folder/%s/metadata' % folder['_id'],
                            method='PUT', user=self.admin,
                            body=json.dumps(metadata), type='application/json')

        folder = resp.json
        self.assertEqual(folder['meta']['foo'], metadata['foo'])
        self.assertNotHasKeys(folder['meta'], ['test'])

        # Make sure metadata cannot be added if there is a period in the key
        # name
        metadata = {
            'foo.bar': 'notallowed'
        }
        resp = self.request(path='/folder/%s/metadata' % folder['_id'],
                            method='PUT', user=self.admin,
                            body=json.dumps(metadata), type='application/json')
        self.assertStatus(resp, 400)
        self.assertEqual(resp.json['message'],
                         'The key name foo.bar must not contain a period' +
                         ' or begin with a dollar sign.')

        # Make sure metadata cannot be added if the key begins with a
        # dollar sign
        metadata = {
            '$foobar': 'alsonotallowed'
        }
        resp = self.request(path='/folder/%s/metadata' % folder['_id'],
                            method='PUT', user=self.admin,
                            body=json.dumps(metadata), type='application/json')
        self.assertStatus(resp, 400)
        self.assertEqual(resp.json['message'],
                         'The key name $foobar must not contain a period' +
                         ' or begin with a dollar sign.')
Base path for all mapreduce-related urls.
dataset/ETHPy150Open girder/girder/tests/cases/folder_test.py/FolderTestCase.testFolderMetadataCrud--crossover with--dataset/ETHPy150Open GoogleCloudPlatform/appengine-mapreduce/python/src/mapreduce/base_handler.py/JsonHandler.base_path