'Test if moderation flag works'

def test_moderated_upload(self):

    with self.settings(ADMIN_MODERATE_UPLOADS=False):
        layer_upload_url = reverse('layer_upload')
        self.client.login(username=self.user, password=self.passwd)
        (input_paths, suffixes) = self._get_input_paths()
        input_files = [open(fp, 'rb') for fp in input_paths]
        files = dict(zip(['{}_file'.format(s) for s in suffixes], input_files))
        files['base_file'] = files.pop('shp_file')
        with contextlib.nested(*input_files):
            files['permissions'] = '{}'
            files['charset'] = 'utf-8'
            files['layer_title'] = 'test    layer'
            resp = self.client.post(layer_upload_url, data=files)
        self.assertEqual(resp.status_code, 200)
        data = json.loads(resp.content)
        lname = data['url'].split(':')[(-1)]
        l = Layer.objects.get(name=lname)
        self.assertTrue(l.is_published)
    with self.settings(ADMIN_MODERATE_UPLOADS=True):
        layer_upload_url = reverse('layer_upload')
        self.client.login(username=self.user, password=self.passwd)
        (input_paths, suffixes) = self._get_input_paths()
        input_files = [open(fp, 'rb') for fp in input_paths]
        files = dict(zip(['{}_file'.format(s) for s in suffixes], input_files))
        files['base_file'] = files.pop('shp_file')
        with contextlib.nested(*input_files):
            files['permissions'] = '{}'
            files['charset'] = 'utf-8'
            files['layer_title'] = 'test    layer'
            resp = self.client.post(layer_upload_url, data=files)
        self.assertEqual(resp.status_code, 200)
        data = json.loads(resp.content)
        lname = data['url'].split(':')[(-1)]
        l = Layer.objects.get(name=lname)
        self.assertFalse(l.is_published)
