def test_export(self):
    collection = self.res.collection.create(name='Test export annotation')
    (reads_1, reads_2) = self.get_reads(2, collection)
    sample_1 = reads_1.sample
    sample_1.name = 'Sample 1'
    sample_1.save()
    sample_2 = reads_2.sample
    sample_2.name = 'Sample 2'
    ann_2 = {'sample': {'genotype': '', 'cell_type': 'Mixed', 'optional_char': ['LIBRARY_STRATEGY:Illumina Standard Prep ', 'OTHER_CHAR_1:2x75 bp', 'OTHER_CHAR_2:subdural cortical tumor, frontal/lateral location. Easily isolated sample', 'TISSUE:Tumor'], 'strain': 'N/A', 'source': 'Tumor', 'organism': 'Homo sapiens', 'molecule': 'total RNA', 'annotator': 'Tristan Brown', 'description': ''}}
    sample_2.descriptor_schema = 'sample'
    sample_2.descriptor = ann_2
    sample_2.save()
    reads_ann = {'experiment_type': 'RNA-Seq', 'protocols': {'growth_protocol': 'N/A', 'treatment_protocol': 'Control'}}
    reads_2.descriptor_schema = 'reads'
    reads_2.descriptor = reads_ann
    reads_2.save()
    filepath = 'annotation_template1.xlsm'
    try:
        os.remove(filepath)
    except OSError:
        pass
    with self.assertLogs() as logs:
        collection.export_annotation(filepath)
    assert os.path.exists(filepath)
    os.remove(filepath)
    self.assertEqual(len(logs.output), 3)
    not_annotated = "WARNING:resdk.data_upload.samplesheet:Sample 'Sample 1' reads not annotated."
    self.assertIn(not_annotated, logs.output)
    location = 'INFO:resdk.data_upload.annotate_samples:\nSample annotation template exported to annotation_template1.xlsm.\n'
    self.assertIn(location, logs.output)
def test_export(self):
    collection = self.res.collection.create(name='Test export annotation')
    (reads_1, reads_2) = self.get_reads(2, collection)
    sample_1 = reads_1.sample
    sample_1.name = 'Sample 1'
    sample_1.save()
    sample_2 = reads_2.sample
    sample_2.name = 'Sample 2'
    ann_2 = {'sample': {'genotype': , 'cell_type': 'Mixed', 'optional_char': ['LIBRARY_STRATEGY:Illumina Standard Prep ', 'OTHER_CHAR_1:2x75 bp', 'OTHER_CHAR_2:subdural cortical tumor, frontal/lateral location. Easily isolated sample', 'TISSUE:Tumor'], 'strain': 'N/A', 'source': 'Tumor', 'organism': 'Homo sapiens', 'molecule': 'total RNA', 'annotator': 'Tristan Brown', 'description': }}
    sample_2.descriptor_schema = 'sample'
    sample_2.descriptor = ann_2
    sample_2.save()
    reads_ann = {'experiment_type': 'RNA-Seq', 'protocols': {'growth_protocol': 'N/A', 'treatment_protocol': 'Control'}}
    reads_2.descriptor_schema = 'reads'
    reads_2.descriptor = reads_ann
    reads_2.save()
    filepath = 'annotation_template1.xlsm'
    try:
        os.remove(filepath)
    except OSError:
        pass
    with self.assertLogs() as logs:
        collection.export_annotation(filepath)
    assert os.path.exists(filepath)
    os.remove(filepath)
    self.assertEqual(len(logs.output), 3)
    not_annotated = "WARNING:resdk.data_upload.samplesheet:Sample 'Sample 1' reads not annotated."
    self.assertIn(not_annotated, logs.output)
    location = 'INFO:resdk.data_upload.annotate_samples:\nSample annotation template exported to annotation_template1.xlsm.\n'
    self.assertIn(location, logs.output)