Exemplo n.º 1
0
    def test_notify_file_archiver(self, expand_curie):
        archive_submission = MagicMock(ArchiveSubmission)
        archive_submission.get_url = MagicMock(return_value='url')

        mock_manifest = self._mock_manifest(self.base_manifest)
        mock_manifest.get_library_preparation_protocol = MagicMock(
            return_value=self.base_manifest.get(
                'library_preparation_protocol_10x'))

        seq_files = self.base_manifest.get('files')
        seq_file = copy.deepcopy(seq_files[0])
        seq_file['content']['file_core']['file_name'] = "R2.fastq.gz"
        seq_files.append(seq_file)
        mock_manifest.get_files = MagicMock(return_value=seq_files)
        ingest_api = copy.deepcopy(self.ingest_api)
        ingest_api.get_manifest_by_id = MagicMock(
            return_value={'bundleUuid': 'dcp_uuid'})
        archiver = IngestArchiver(ingest_api=ingest_api,
                                  dsp_api=self.dsp_api,
                                  ontology_api=self.ontology_api)
        archiver.get_manifest = MagicMock(return_value=mock_manifest)
        entity_map = archiver.convert(['bundle_uuid'])
        archive_submission.converted_entities = list(
            entity_map.get_converted_entities())
        archive_submission.entity_map = entity_map

        messages = archiver.notify_file_archiver(archive_submission)

        expected = {
            "dsp_api_url": 'dsp_url',
            "dcp_bundle_uuid": 'dcp_uuid',
            'submission_url': 'url',
            'files': [{
                'name': 'dummy_manifest_id.bam'
            }],
            'conversion': {
                'output_name':
                'dummy_manifest_id.bam',
                'schema':
                '10xV2',
                'inputs': [{
                    'name':
                    'R1.fastq.gz',
                    'read_index':
                    'read1',
                    'cloud_url':
                    's3://org-humancellatlas-upload-dev/8cd91cfd-0374-454f-ac83-8db6581d2706/R1.fastq.gz'
                }, {
                    'name':
                    'R2.fastq.gz',
                    'read_index':
                    'read1',
                    'cloud_url':
                    's3://org-humancellatlas-upload-dev/8cd91cfd-0374-454f-ac83-8db6581d2706/R1.fastq.gz'
                }]
            },
            'manifest_id': 'dummy_manifest_id'
        }
        self.assertTrue(messages)
        self.assertEqual(expected, messages[0])
Exemplo n.º 2
0
    def test_get_archivable_entities(self, expand_curie):
        mock_manifest = self._mock_manifest(self.base_manifest)

        archiver = IngestArchiver(ontology_api=self.ontology_api,
                                  ingest_api=self.ingest_api,
                                  dsp_api=self.dsp_api,
                                  exclude_types=['sequencingRun'])
        archiver.get_manifest = MagicMock(return_value=mock_manifest)
        entity_map = archiver.convert(['manifest_id'])
        entities_by_type = entity_map.entities_dict_type
        self.assertTrue(entities_by_type.get('project'))
        self.assertTrue(entities_by_type.get('study'))
        self.assertTrue(entities_by_type.get('sample'))
        self.assertTrue(entities_by_type.get('sequencingExperiment'))
Exemplo n.º 3
0
    def test_archive(self):
        mock_manifest = self._mock_manifest(self.base_manifest)
        archiver = IngestArchiver(ontology_api=self.ontology_api,
                                  ingest_api=self.ingest_api,
                                  dsp_api=self.dsp_api,
                                  exclude_types=['sequencingRun'])
        archiver.get_manifest = MagicMock(return_value=mock_manifest)
        entity_map = archiver.convert(['bundle_uuid'])
        archive_submission = archiver.archive(entity_map)
        self.assertTrue(archive_submission.is_completed)

        for entity in archive_submission.entity_map.get_entities():
            self.assertTrue(archive_submission.accession_map.get(entity.id),
                            f"{entity.id} has no accession.")
Exemplo n.º 4
0
    def test_validate_and_complete_submission(self):
        mock_manifest = self._mock_manifest(self.base_manifest)
        archiver = IngestArchiver(ontology_api=self.ontology_api,
                                  ingest_api=self.ingest_api,
                                  dsp_api=self.dsp_api,
                                  exclude_types=['sequencingRun'])
        archiver.get_manifest = MagicMock(return_value=mock_manifest)
        entity_map = archiver.convert(['bundle_uuid'])
        archive_submission, _ = archiver.archive_metadata(entity_map)
        url = archive_submission.get_url()

        archive_submission = archiver.complete_submission(
            dsp_submission_url=url)
        self.assertTrue(archive_submission.is_completed)
        self.assertTrue(archive_submission.accession_map)
Exemplo n.º 5
0
    def test_archive_skip_metadata_with_accessions(self):
        with open(config.JSON_DIR + 'hca/biomaterial_with_accessions.json',
                  encoding=config.ENCODING) as data_file:
            biomaterials = json.loads(data_file.read())
        biomaterial_manifest = {'biomaterials': biomaterials}
        mock_manifest = self._mock_manifest(biomaterial_manifest)
        archiver = IngestArchiver(ontology_api=self.ontology_api,
                                  ingest_api=self.ingest_api,
                                  dsp_api=self.dsp_api,
                                  exclude_types=['sequencingRun'])
        archiver.get_manifest = MagicMock(return_value=mock_manifest)
        entity_map = archiver.convert('')
        archive_submission = archiver.archive(entity_map)

        self.assertTrue(archive_submission.is_completed)
        self.assertTrue(archive_submission.errors)
        self.assertFalse(archive_submission.processing_result)