Beispiel #1
0
    def test_download(self):
        # check success
        response = self.get('/download/1')
        self.assertEqual(response.code, 200)
        self.assertEqual(response.body.decode('ascii'), (
            "This installation of Qiita was not equipped with nginx, so it "
            "is incapable of serving files. The file you attempted to "
            "download is located at raw_data/1_s_G1_L001_sequences.fastq.gz"))
        self.assertEqual(
            response.headers['Content-Disposition'],
            "attachment; filename=1_1_s_G1_L001_sequences.fastq.gz")
        # other tests to validate the filename
        response = self.get('/download/2')
        self.assertEqual(
            response.headers['Content-Disposition'],
            "attachment; filename=1_1_s_G1_L001_sequences_barcodes.fastq.gz")
        response = self.get('/download/3')
        self.assertEqual(
            response.headers['Content-Disposition'],
            "attachment; filename=2_1_seqs.fna")
        response = self.get('/download/18')
        self.assertEqual(
            response.headers['Content-Disposition'],
            "attachment; filename=1_prep_1_19700101-000000.txt")
        response = self.get('/download/22')
        self.assertEqual(
            response.headers['Content-Disposition'],
            "attachment; filename=7_biom_table.biom")

        # failure
        response = self.get('/download/1000')
        self.assertEqual(response.code, 403)

        # directory
        a = Artifact(1)
        fd, fp = mkstemp(suffix='.html')
        close(fd)
        with open(fp, 'w') as f:
            f.write('\n')
        self._clean_up_files.append(fp)
        dirpath = mkdtemp()
        fd, fp2 = mkstemp(suffix='.txt', dir=dirpath)
        close(fd)
        with open(fp2, 'w') as f:
            f.write('\n')
        self._clean_up_files.append(dirpath)
        a.set_html_summary(fp, support_dir=dirpath)
        for x in a.filepaths:
            if x['fp_type'] == 'html_summary_dir':
                break
        response = self.get('/download/%d' % x['fp_id'])
        self.assertEqual(response.code, 200)

        fp_name = basename(fp2)
        dirname = basename(dirpath)
        self.assertEqual(response.body.decode('ascii'),
                         "- 1 /protected/FASTQ/1/%s/%s FASTQ/1/%s/%s\n" % (
                            dirname, fp_name, dirname, fp_name))
    def test_get_artifact_summary_handler(self):
        a = Artifact(1)
        # Add a summary to the artifact
        fd, fp = mkstemp(suffix=".html")
        close(fd)
        with open(fp, 'w') as f:
            f.write('<b>HTML TEST - not important</b>\n')
        a = Artifact(1)
        a.set_html_summary(fp)
        self._files_to_remove.extend([fp, a.html_summary_fp[1]])

        summary = relpath(a.html_summary_fp[1], qiita_config.base_data_dir)
        response = self.get('/artifact/html_summary/%s' % summary)
        self.assertEqual(response.code, 200)
        self.assertEqual(response.body, '<b>HTML TEST - not important</b>\n')
Beispiel #3
0
    def test_download(self):
        # check success
        response = self.get('/download/1')
        self.assertEqual(response.code, 200)
        self.assertEqual(response.body, (
            "This installation of Qiita was not equipped with nginx, so it "
            "is incapable of serving files. The file you attempted to "
            "download is located at raw_data/1_s_G1_L001_sequences.fastq.gz"))

        # failure
        response = self.get('/download/1000')
        self.assertEqual(response.code, 403)

        # directory
        a = Artifact(1)
        fd, fp = mkstemp(suffix='.html')
        close(fd)
        with open(fp, 'w') as f:
            f.write('\n')
        self._clean_up_files.append(fp)
        dirpath = mkdtemp()
        fd, fp2 = mkstemp(suffix='.txt', dir=dirpath)
        close(fd)
        with open(fp2, 'w') as f:
            f.write('\n')
        self._clean_up_files.append(dirpath)
        a.set_html_summary(fp, support_dir=dirpath)
        for fp_id, _, fp_type in a.filepaths:
            if fp_type == 'html_summary_dir':
                break
        response = self.get('/download/%d' % fp_id)
        self.assertEqual(response.code, 200)

        fp_name = basename(fp2)
        dirname = basename(dirpath)
        self.assertEqual(
            response.body, "- 1 /protected/FASTQ/1/%s/%s FASTQ/1/%s/%s\n"
                           % (dirname, fp_name, dirname, fp_name))
Beispiel #4
0
    def test_artifact_summary_get_request(self):
        user = User('*****@*****.**')
        main_buttons = (
            '<button onclick="if (confirm('
            "\'Are you sure you want to make "
            "public artifact id: 1?')) { set_artifact_visibility('public', 1) "
            '}" class="btn btn-primary btn-sm">Make public</button> <button '
            'onclick="if (confirm('
            "'Are you sure you want to revert to "
            "sandbox artifact id: 1?')) { set_artifact_visibility('sandbox', 1"
            ') }" class="btn btn-primary btn-sm">Revert to sandbox</button> ')
        private_download_button = (
            '<button class="btn btn-primary btn-sm" type="button" '
            'aria-expanded="false" aria-controls="privateDownloadLink" '
            'onclick="generate_private_download_link(%s)">Generate Download '
            'Link</button><div class="collapse" id="privateDownloadLink"><div '
            'class="card card-body" id="privateDownloadText">Generating '
            'Download Link...</div></div>')
        # Artifact w/o summary
        obs = artifact_summary_get_request(user, 1)
        exp_files = [
            (1, '1_s_G1_L001_sequences.fastq.gz (raw forward seqs)',
             '2125826711', '58B'),
            (2, '1_s_G1_L001_sequences_barcodes.fastq.gz (raw barcodes)',
             '2125826711', '58B')
        ]
        exp = {
            'name': 'Raw data 1',
            'artifact_id': 1,
            'artifact_type': 'FASTQ',
            'being_deleted': False,
            'artifact_timestamp': '2012-10-01 09:10',
            'visibility': 'private',
            'editable': True,
            'buttons': main_buttons + private_download_button % 1,
            'processing_info': {},
            'files': exp_files,
            'is_from_analysis': False,
            'summary': None,
            'job': None,
            'errored_summary_jobs': []
        }
        self.assertEqual(obs, exp)

        # Artifact with summary being generated
        job = ProcessingJob.create(
            User('*****@*****.**'),
            Parameters.load(Command(7), values_dict={'input_data': 1}))
        job._set_status('queued')
        obs = artifact_summary_get_request(user, 1)
        exp = {
            'name': 'Raw data 1',
            'artifact_id': 1,
            'artifact_type': 'FASTQ',
            'being_deleted': False,
            'artifact_timestamp': '2012-10-01 09:10',
            'visibility': 'private',
            'editable': True,
            'buttons': main_buttons + private_download_button % 1,
            'processing_info': {},
            'files': exp_files,
            'is_from_analysis': False,
            'summary': None,
            'job': [job.id, 'queued', None],
            'errored_summary_jobs': []
        }
        self.assertEqual(obs, exp)

        # Artifact with summary
        fd, fp = mkstemp(suffix=".html")
        close(fd)
        with open(fp, 'w') as f:
            f.write('<b>HTML TEST - not important</b>\n')
        a = Artifact(1)
        a.set_html_summary(fp)
        self._files_to_remove.extend([fp, a.html_summary_fp[1]])
        exp_files.append((a.html_summary_fp[0],
                          '%s (html summary)' % basename(a.html_summary_fp[1]),
                          '1642196267', '33B'))
        exp_summary_path = relpath(a.html_summary_fp[1],
                                   qiita_config.base_data_dir)
        obs = artifact_summary_get_request(user, 1)
        exp = {
            'name': 'Raw data 1',
            'artifact_id': 1,
            'artifact_type': 'FASTQ',
            'being_deleted': False,
            'artifact_timestamp': '2012-10-01 09:10',
            'visibility': 'private',
            'editable': True,
            'buttons': main_buttons + private_download_button % 1,
            'processing_info': {},
            'files': exp_files,
            'is_from_analysis': False,
            'summary': exp_summary_path,
            'job': None,
            'errored_summary_jobs': []
        }
        self.assertEqual(obs, exp)

        # No access
        demo_u = User('*****@*****.**')
        with self.assertRaises(QiitaHTTPError):
            obs = artifact_summary_get_request(demo_u, 1)

        # A non-owner/share user can't see the files
        a.visibility = 'public'
        obs = artifact_summary_get_request(demo_u, 1)
        exp = {
            'name': 'Raw data 1',
            'artifact_id': 1,
            'artifact_type': 'FASTQ',
            'being_deleted': False,
            'artifact_timestamp': '2012-10-01 09:10',
            'visibility': 'public',
            'editable': False,
            'buttons': '',
            'processing_info': {},
            'files': [],
            'is_from_analysis': False,
            'summary': exp_summary_path,
            'job': None,
            'errored_summary_jobs': []
        }
        self.assertEqual(obs, exp)

        # testing sandbox
        a.visibility = 'sandbox'
        obs = artifact_summary_get_request(user, 1)
        exp = {
            'name': 'Raw data 1',
            'artifact_id': 1,
            'artifact_type': 'FASTQ',
            'being_deleted': False,
            'artifact_timestamp': '2012-10-01 09:10',
            'visibility': 'sandbox',
            'editable': True,
            'buttons': private_download_button % 1,
            'processing_info': {},
            'files': exp_files,
            'is_from_analysis': False,
            'summary': exp_summary_path,
            'job': None,
            'errored_summary_jobs': []
        }
        self.assertEqual(obs, exp)

        # returnig to private
        a.visibility = 'private'

        # admin gets buttons
        obs = artifact_summary_get_request(User('*****@*****.**'), 2)
        exp_files = [(3, '1_seqs.fna (preprocessed fasta)', '', '0B'),
                     (4, '1_seqs.qual (preprocessed fastq)', '', '0B'),
                     (5, '1_seqs.demux (preprocessed demux)', '', '0B')]
        exp = {
            'name':
            'Demultiplexed 1',
            'artifact_id':
            2,
            'artifact_type':
            'Demultiplexed',
            'being_deleted':
            False,
            'artifact_timestamp':
            '2012-10-01 10:10',
            'visibility':
            'private',
            'editable':
            True,
            'buttons': ('<button onclick="if (confirm(\'Are you sure you '
                        'want to make public artifact id: 2?\')) { '
                        'set_artifact_visibility(\'public\', 2) }" '
                        'class="btn btn-primary btn-sm">Make public'
                        '</button> <button onclick="if (confirm(\'Are you '
                        'sure you want to revert to sandbox artifact id: '
                        '2?\')) { set_artifact_visibility(\'sandbox\', 2) '
                        '}" class="btn btn-primary btn-sm">Revert to '
                        'sandbox</button> <a class="btn btn-primary '
                        'btn-sm" href="/ebi_submission/2"><span '
                        'class="glyphicon glyphicon-export"></span> '
                        'Submit to EBI</a> <a class="btn btn-primary '
                        'btn-sm" href="/vamps/2"><span class="glyphicon '
                        'glyphicon-export"></span> Submit to VAMPS</a> ' +
                        private_download_button % 2),
            'processing_info': {
                'command_active': True,
                'software_deprecated': False,
                'command': 'Split libraries FASTQ',
                'processing_parameters': {
                    'max_barcode_errors': '1.5',
                    'sequence_max_n': '0',
                    'max_bad_run_length': '3',
                    'phred_offset': 'auto',
                    'rev_comp': 'False',
                    'phred_quality_threshold': '3',
                    'input_data': '1',
                    'rev_comp_barcode': 'False',
                    'rev_comp_mapping_barcodes': 'False',
                    'min_per_read_length_fraction': '0.75',
                    'barcode_type': 'golay_12'
                },
                'software_version': '1.9.1',
                'software': 'QIIME'
            },
            'files':
            exp_files,
            'is_from_analysis':
            False,
            'summary':
            None,
            'job':
            None,
            'errored_summary_jobs': []
        }
        self.assertEqual(obs, exp)

        # the buttons shouldn't be present when the study is autoloaded
        study = a.study
        study.autoloaded = True
        exp['buttons'] = ('<button onclick="if (confirm(\'Are you sure you '
                          'want to make public artifact id: 2?\')) { '
                          'set_artifact_visibility(\'public\', 2) }" '
                          'class="btn btn-primary btn-sm">Make public'
                          '</button> <button onclick="if (confirm(\'Are you '
                          'sure you want to revert to sandbox artifact id: '
                          '2?\')) { set_artifact_visibility(\'sandbox\', 2) '
                          '}" class="btn btn-primary btn-sm">Revert to '
                          'sandbox</button> ' + private_download_button % 2)
        obs = artifact_summary_get_request(User('*****@*****.**'), 2)
        self.assertEqual(obs, exp)
        study.autoloaded = False

        # analysis artifact
        obs = artifact_summary_get_request(user, 8)
        exp = {
            'name': 'noname',
            'artifact_id': 8,
            'artifact_type': 'BIOM',
            'being_deleted': False,
            # this value changes on build so copy from obs
            'artifact_timestamp': obs['artifact_timestamp'],
            'visibility': 'sandbox',
            'editable': True,
            'buttons': private_download_button % 8,
            'processing_info': {},
            'files': [(22, 'biom_table.biom (biom)', '1756512010', '1.0M')],
            'is_from_analysis': True,
            'summary': None,
            'job': None,
            'errored_summary_jobs': []
        }
        self.assertEqual(obs, exp)
    def test_artifact_summary_get_request(self):
        user = User('*****@*****.**')
        # Artifact w/o summary
        obs = artifact_summary_get_request(user, 1)
        exp_files = [
            (1L, '1_s_G1_L001_sequences.fastq.gz (raw forward seqs)'),
            (2L, '1_s_G1_L001_sequences_barcodes.fastq.gz (raw barcodes)')]
        exp = {'name': 'Raw data 1',
               'artifact_id': 1,
               'artifact_type': 'FASTQ',
               'artifact_timestamp': '2012-10-01 09:10',
               'visibility': 'private',
               'editable': True,
               'buttons': ('<button onclick="if (confirm(\'Are you sure you '
                           'want to make public artifact id: 1?\')) { '
                           'set_artifact_visibility(\'public\', 1) }" '
                           'class="btn btn-primary btn-sm">Make public'
                           '</button> <button onclick="if (confirm(\'Are you '
                           'sure you want to revert to sandbox artifact id: '
                           '1?\')) { set_artifact_visibility(\'sandbox\', 1) '
                           '}" class="btn btn-primary btn-sm">Revert to '
                           'sandbox</button>'),
               'processing_info': {},
               'files': exp_files,
               'is_from_analysis': False,
               'summary': None,
               'job': None,
               'errored_summary_jobs': []}
        self.assertEqual(obs, exp)

        # Artifact with summary being generated
        job = ProcessingJob.create(
            User('*****@*****.**'),
            Parameters.load(Command(7), values_dict={'input_data': 1})
        )
        job._set_status('queued')
        obs = artifact_summary_get_request(user, 1)
        exp = {'name': 'Raw data 1',
               'artifact_id': 1,
               'artifact_type': 'FASTQ',
               'artifact_timestamp': '2012-10-01 09:10',
               'visibility': 'private',
               'editable': True,
               'buttons': ('<button onclick="if (confirm(\'Are you sure you '
                           'want to make public artifact id: 1?\')) { '
                           'set_artifact_visibility(\'public\', 1) }" '
                           'class="btn btn-primary btn-sm">Make public'
                           '</button> <button onclick="if (confirm(\'Are you '
                           'sure you want to revert to sandbox artifact id: '
                           '1?\')) { set_artifact_visibility(\'sandbox\', 1) '
                           '}" class="btn btn-primary btn-sm">Revert to '
                           'sandbox</button>'),
               'processing_info': {},
               'files': exp_files,
               'is_from_analysis': False,
               'summary': None,
               'job': [job.id, 'queued', None],
               'errored_summary_jobs': []}
        self.assertEqual(obs, exp)

        # Artifact with summary
        fd, fp = mkstemp(suffix=".html")
        close(fd)
        with open(fp, 'w') as f:
            f.write('<b>HTML TEST - not important</b>\n')
        a = Artifact(1)
        a.set_html_summary(fp)
        self._files_to_remove.extend([fp, a.html_summary_fp[1]])
        exp_files.append(
            (a.html_summary_fp[0],
             '%s (html summary)' % basename(a.html_summary_fp[1])))
        exp_summary_path = relpath(
            a.html_summary_fp[1], qiita_config.base_data_dir)
        obs = artifact_summary_get_request(user, 1)
        exp = {'name': 'Raw data 1',
               'artifact_id': 1,
               'artifact_type': 'FASTQ',
               'artifact_timestamp': '2012-10-01 09:10',
               'visibility': 'private',
               'editable': True,
               'buttons': ('<button onclick="if (confirm(\'Are you sure you '
                           'want to make public artifact id: 1?\')) { '
                           'set_artifact_visibility(\'public\', 1) }" '
                           'class="btn btn-primary btn-sm">Make public'
                           '</button> <button onclick="if (confirm(\'Are you '
                           'sure you want to revert to sandbox artifact id: '
                           '1?\')) { set_artifact_visibility(\'sandbox\', 1) '
                           '}" class="btn btn-primary btn-sm">Revert to '
                           'sandbox</button>'),
               'processing_info': {},
               'files': exp_files,
               'is_from_analysis': False,
               'summary': exp_summary_path,
               'job': None,
               'errored_summary_jobs': []}
        self.assertEqual(obs, exp)

        # No access
        demo_u = User('*****@*****.**')
        with self.assertRaises(QiitaHTTPError):
            obs = artifact_summary_get_request(demo_u, 1)

        # A non-owner/share user can't see the files
        a.visibility = 'public'
        obs = artifact_summary_get_request(demo_u, 1)
        exp = {'name': 'Raw data 1',
               'artifact_id': 1,
               'artifact_type': 'FASTQ',
               'artifact_timestamp': '2012-10-01 09:10',
               'visibility': 'public',
               'editable': False,
               'buttons': '',
               'processing_info': {},
               'files': [],
               'is_from_analysis': False,
               'summary': exp_summary_path,
               'job': None,
               'errored_summary_jobs': []}
        self.assertEqual(obs, exp)

        # returnig to private
        a.visibility = 'private'

        # admin gets buttons
        obs = artifact_summary_get_request(User('*****@*****.**'), 2)
        exp_files = [
            (3L, '1_seqs.fna (preprocessed fasta)'),
            (4L, '1_seqs.qual (preprocessed fastq)'),
            (5L, '1_seqs.demux (preprocessed demux)')]
        exp = {'name': 'Demultiplexed 1',
               'artifact_id': 2,
               'artifact_type': 'Demultiplexed',
               'artifact_timestamp': '2012-10-01 10:10',
               'visibility': 'private',
               'editable': True,
               'buttons': ('<button onclick="if (confirm(\'Are you sure you '
                           'want to make public artifact id: 2?\')) { '
                           'set_artifact_visibility(\'public\', 2) }" '
                           'class="btn btn-primary btn-sm">Make public'
                           '</button> <button onclick="if (confirm(\'Are you '
                           'sure you want to revert to sandbox artifact id: '
                           '2?\')) { set_artifact_visibility(\'sandbox\', 2) '
                           '}" class="btn btn-primary btn-sm">Revert to '
                           'sandbox</button> <a class="btn btn-primary '
                           'btn-sm" href="/ebi_submission/2"><span '
                           'class="glyphicon glyphicon-export"></span> '
                           'Submit to EBI</a> <a class="btn btn-primary '
                           'btn-sm" href="/vamps/2"><span class="glyphicon '
                           'glyphicon-export"></span> Submit to VAMPS</a>'),
               'processing_info': {
                    'command': 'Split libraries FASTQ',
                    'software': 'QIIME',
                    'software_version': '1.9.1',
                    'processing_parameters': {
                        'max_barcode_errors': '1.5', 'sequence_max_n': '0',
                        'max_bad_run_length': '3', 'phred_offset': u'auto',
                        'rev_comp': 'False', 'phred_quality_threshold': '3',
                        'input_data': '1', 'rev_comp_barcode': 'False',
                        'rev_comp_mapping_barcodes': 'False',
                        'min_per_read_length_fraction': '0.75',
                        'barcode_type': u'golay_12'}},
               'files': exp_files,
               'is_from_analysis': False,
               'summary': None,
               'job': None,
               'errored_summary_jobs': []}
        self.assertEqual(obs, exp)

        # analysis artifact
        obs = artifact_summary_get_request(user, 8)
        exp = {'name': 'noname',
               'artifact_id': 8,
               'artifact_type': 'BIOM',
               # this value changes on build so copy from obs
               'artifact_timestamp': obs['artifact_timestamp'],
               'visibility': 'sandbox',
               'editable': True,
               'buttons': '',
               'processing_info': {},
               'files': [(27, 'biom_table.biom (biom)')],
               'is_from_analysis': True,
               'summary': None,
               'job': None,
               'errored_summary_jobs': []}
        self.assertEqual(obs, exp)
    def test_artifact_summary_get_request(self):
        user = User('*****@*****.**')
        # Artifact w/o summary
        obs = artifact_summary_get_request(user, 1)
        exp_p_jobs = [[
            '063e553b-327c-4818-ab4a-adfe58e49860', 'Split libraries FASTQ',
            'queued', None, None
        ],
                      [
                          'bcc7ebcd-39c1-43e4-af2d-822e3589f14d',
                          'Split libraries', 'running', 'demultiplexing', None
                      ]]
        exp_files = [
            (1L, '1_s_G1_L001_sequences.fastq.gz (raw forward seqs)'),
            (2L, '1_s_G1_L001_sequences_barcodes.fastq.gz (raw barcodes)')
        ]
        exp = {
            'name':
            'Raw data 1',
            'artifact_id':
            1,
            'artifact_type':
            'FASTQ',
            'artifact_timestamp':
            '2012-10-01 09:10',
            'visibility':
            'private',
            'editable':
            True,
            'buttons': ('<button onclick="if (confirm(\'Are you sure you '
                        'want to make public artifact id: 1?\')) { '
                        'set_artifact_visibility(\'public\', 1) }" '
                        'class="btn btn-primary btn-sm">Make public'
                        '</button> <button onclick="if (confirm(\'Are you '
                        'sure you want to revert to sandbox artifact id: '
                        '1?\')) { set_artifact_visibility(\'sandbox\', 1) '
                        '}" class="btn btn-primary btn-sm">Revert to '
                        'sandbox</button>'),
            'processing_parameters': {},
            'files':
            exp_files,
            'is_from_analysis':
            False,
            'summary':
            None,
            'job':
            None,
            'processing_jobs':
            exp_p_jobs,
            'errored_jobs': []
        }
        self.assertEqual(obs, exp)

        # Artifact with summary being generated
        job = ProcessingJob.create(
            User('*****@*****.**'),
            Parameters.load(Command(7), values_dict={'input_data': 1}))
        job._set_status('queued')
        obs = artifact_summary_get_request(user, 1)
        exp = {
            'name':
            'Raw data 1',
            'artifact_id':
            1,
            'artifact_type':
            'FASTQ',
            'artifact_timestamp':
            '2012-10-01 09:10',
            'visibility':
            'private',
            'editable':
            True,
            'buttons': ('<button onclick="if (confirm(\'Are you sure you '
                        'want to make public artifact id: 1?\')) { '
                        'set_artifact_visibility(\'public\', 1) }" '
                        'class="btn btn-primary btn-sm">Make public'
                        '</button> <button onclick="if (confirm(\'Are you '
                        'sure you want to revert to sandbox artifact id: '
                        '1?\')) { set_artifact_visibility(\'sandbox\', 1) '
                        '}" class="btn btn-primary btn-sm">Revert to '
                        'sandbox</button>'),
            'processing_parameters': {},
            'files':
            exp_files,
            'is_from_analysis':
            False,
            'summary':
            None,
            'job': [job.id, 'queued', None],
            'processing_jobs':
            exp_p_jobs,
            'errored_jobs': []
        }
        self.assertEqual(obs, exp)

        # Artifact with summary
        fd, fp = mkstemp(suffix=".html")
        close(fd)
        with open(fp, 'w') as f:
            f.write('<b>HTML TEST - not important</b>\n')
        a = Artifact(1)
        a.set_html_summary(fp)
        self._files_to_remove.extend([fp, a.html_summary_fp[1]])
        exp_files.append(
            (a.html_summary_fp[0],
             '%s (html summary)' % basename(a.html_summary_fp[1])))
        exp_summary_path = relpath(a.html_summary_fp[1],
                                   qiita_config.base_data_dir)
        obs = artifact_summary_get_request(user, 1)
        exp = {
            'name':
            'Raw data 1',
            'artifact_id':
            1,
            'artifact_type':
            'FASTQ',
            'artifact_timestamp':
            '2012-10-01 09:10',
            'visibility':
            'private',
            'editable':
            True,
            'buttons': ('<button onclick="if (confirm(\'Are you sure you '
                        'want to make public artifact id: 1?\')) { '
                        'set_artifact_visibility(\'public\', 1) }" '
                        'class="btn btn-primary btn-sm">Make public'
                        '</button> <button onclick="if (confirm(\'Are you '
                        'sure you want to revert to sandbox artifact id: '
                        '1?\')) { set_artifact_visibility(\'sandbox\', 1) '
                        '}" class="btn btn-primary btn-sm">Revert to '
                        'sandbox</button>'),
            'processing_parameters': {},
            'files':
            exp_files,
            'is_from_analysis':
            False,
            'summary':
            exp_summary_path,
            'job':
            None,
            'processing_jobs':
            exp_p_jobs,
            'errored_jobs': []
        }
        self.assertEqual(obs, exp)

        # No access
        demo_u = User('*****@*****.**')
        with self.assertRaises(QiitaHTTPError):
            obs = artifact_summary_get_request(demo_u, 1)

        # A non-owner/share user can't see the files
        a.visibility = 'public'
        obs = artifact_summary_get_request(demo_u, 1)
        exp = {
            'name': 'Raw data 1',
            'artifact_id': 1,
            'artifact_type': 'FASTQ',
            'artifact_timestamp': '2012-10-01 09:10',
            'visibility': 'public',
            'editable': False,
            'buttons': '',
            'processing_parameters': {},
            'files': [],
            'is_from_analysis': False,
            'summary': exp_summary_path,
            'job': None,
            'processing_jobs': exp_p_jobs,
            'errored_jobs': []
        }
        self.assertEqual(obs, exp)

        # returnig to private
        a.visibility = 'private'

        # admin gets buttons
        obs = artifact_summary_get_request(User('*****@*****.**'), 2)
        exp_p_jobs = [[
            'd19f76ee-274e-4c1b-b3a2-a12d73507c55',
            'Pick closed-reference OTUs', 'error', 'generating demux file',
            'Error message'
        ]]
        exp_files = [(3L, '1_seqs.fna (preprocessed fasta)'),
                     (4L, '1_seqs.qual (preprocessed fastq)'),
                     (5L, '1_seqs.demux (preprocessed demux)')]
        exp = {
            'name':
            'Demultiplexed 1',
            'artifact_id':
            2,
            'artifact_type':
            'Demultiplexed',
            'artifact_timestamp':
            '2012-10-01 10:10',
            'visibility':
            'private',
            'editable':
            True,
            'buttons': ('<button onclick="if (confirm(\'Are you sure you '
                        'want to make public artifact id: 2?\')) { '
                        'set_artifact_visibility(\'public\', 2) }" '
                        'class="btn btn-primary btn-sm">Make public'
                        '</button> <button onclick="if (confirm(\'Are you '
                        'sure you want to revert to sandbox artifact id: '
                        '2?\')) { set_artifact_visibility(\'sandbox\', 2) '
                        '}" class="btn btn-primary btn-sm">Revert to '
                        'sandbox</button> <a class="btn btn-primary '
                        'btn-sm" href="/ebi_submission/2"><span '
                        'class="glyphicon glyphicon-export"></span> '
                        'Submit to EBI</a> <a class="btn btn-primary '
                        'btn-sm" href="/vamps/2"><span class="glyphicon '
                        'glyphicon-export"></span> Submit to VAMPS</a>'),
            'processing_parameters': {
                'max_barcode_errors': 1.5,
                'sequence_max_n': 0,
                'max_bad_run_length': 3,
                'phred_offset': u'auto',
                'rev_comp': False,
                'phred_quality_threshold': 3,
                'input_data': 1,
                'rev_comp_barcode': False,
                'rev_comp_mapping_barcodes': False,
                'min_per_read_length_fraction': 0.75,
                'barcode_type': u'golay_12'
            },
            'files':
            exp_files,
            'is_from_analysis':
            False,
            'summary':
            None,
            'job':
            None,
            'processing_jobs':
            exp_p_jobs,
            'errored_jobs': []
        }
        self.assertEqual(obs, exp)

        # analysis artifact
        obs = artifact_summary_get_request(user, 8)
        exp = {
            'name': 'noname',
            'artifact_id': 8,
            'artifact_type': 'BIOM',
            # this value changes on build so copy from obs
            'artifact_timestamp': obs['artifact_timestamp'],
            'visibility': 'sandbox',
            'editable': True,
            'buttons': '',
            'processing_parameters': {},
            'files': [(27, 'biom_table.biom (biom)')],
            'is_from_analysis': True,
            'summary': None,
            'job': None,
            'processing_jobs': [],
            'errored_jobs': []
        }
        self.assertEqual(obs, exp)