

def test_get_default_configurations(self):
    app = 'hive'
    properties = [{
        'multiple': True,
        'value': [{
            'path': '/user/test/myudfs.jar',
            'type': 'jar',
        }],
        'nice_name': 'Files',
        'key': 'files',
        'help_text': 'Add one or more files, jars, or archives to the list of resources.',
        'type': 'hdfs-files',
    }, {
        'multiple': True,
        'value': [{
            'class_name': 'org.hue.udf.MyUpper',
            'name': 'myUpper',
        }],
        'nice_name': 'Functions',
        'key': 'functions',
        'help_text': 'Add one or more registered UDFs (requires function name and fully-qualified class name).',
        'type': 'functions',
    }, {
        'multiple': True,
        'value': [{
            'key': 'mapreduce.job.queuename',
            'value': 'mr',
        }],
        'nice_name': 'Settings',
        'key': 'settings',
        'help_text': 'Hive and Hadoop configuration properties.',
        'type': 'settings',
        'options': ['hive.map.aggr', 'hive.exec.compress.output', 'hive.exec.parallel', 'hive.execution.engine', 'mapreduce.job.queuename'],
    }]
    response = self.client.get('/desktop/api/configurations/user', {
        'app': 'hive',
        'user_id': self.user.id,
    })
    content = json.loads(response.content)
    assert_equal(content['status'], 0, content)
    assert_equal(content['configuration'], None, content)
    response = self.client.post('/desktop/api/configurations/save', {
        'app': 'hive',
        'properties': json.dumps(properties),
        'is_default': True,
    })
    response = self.client.get('/desktop/api/configurations/user', {
        'app': 'hive',
        'user_id': self.user.id,
    })
    content = json.loads(response.content)
    assert_equal(content['status'], 0, content)
    assert_equal(content['configuration']['app'], 'hive', content)
    assert_equal(content['configuration']['is_default'], True, content)
    assert_equal(content['configuration']['user'], None, content)
    assert_equal(content['configuration']['group'], None, content)
    assert_equal(content['configuration']['properties'], properties, content)
    properties = {
        'settings': [{
            'key': 'hive.execution.engine',
            'value': 'mr',
        }],
    }
    response = self.client.post('/desktop/api/configurations/save', {
        'app': 'hive',
        'properties': json.dumps(properties),
        'is_default': False,
        'group_id': self.group.id,
    })
    response = self.client.get('/desktop/api/configurations/user', {
        'app': 'hive',
        'user_id': self.user.id,
    })
    content = json.loads(response.content)
    assert_equal(content['status'], 0, content)
    assert_equal(content['configuration']['app'], 'hive', content)
    assert_equal(content['configuration']['is_default'], False, content)
    assert_equal(content['configuration']['user'], None, content)
    assert_equal(content['configuration']['group'], self.group.name, content)
    assert_equal(content['configuration']['properties'], properties, content)
    properties = {
        'files': [{
            'type': 'JAR',
            'path': '/user/test/udfs.jar',
        }],
        'settings': [{
            'key': 'hive.execution.engine',
            'value': 'spark',
        }],
    }
    response = self.client.post('/desktop/api/configurations/save', {
        'app': 'hive',
        'properties': json.dumps(properties),
        'is_default': False,
        'user_id': self.user.id,
    })
    response = self.client.get('/desktop/api/configurations/user', {
        'app': 'hive',
        'user_id': self.user.id,
    })
    content = json.loads(response.content)
    assert_equal(content['status'], 0, content)
    assert_equal(content['configuration']['app'], 'hive', content)
    assert_equal(content['configuration']['is_default'], False, content)
    assert_equal(content['configuration']['user'], self.user.username, content)
    assert_equal(content['configuration']['group'], None, content)
    assert_equal(content['configuration']['properties'], properties, content)

dataset/ETHPy150Open cloudera/hue/desktop/core/src/desktop/configuration/tests.py TestDefaultConfiguration.test_get_default_configurations/original