class TestImportLibraryPrepSamples(unittest.TestCase):
    def setUp(self):
        here = os.path.dirname(__file__)
        file_name = r'BLA-32605-v.4.0_Samples_for_library_preparation_SampleForm_test till validering.xlsx'
        file_path = os.path.join(here, file_name)
        sample_column_index = 4
        volume_column_index = 6
        sample_column_name = 'SAMPLE ID'
        here = os.path.dirname(__file__)
        export_file_path = os.path.join(here, 'newfile.xlsx')
        self.excel_reader = ImportSampleSubmission(file_path,
                                                   sample_column_index,
                                                   volume_column_index,
                                                   sample_column_name,
                                                   export_file_path)

    def test_get_caption_row(self):
        row_index = self.excel_reader._determine_caption_row_index()
        self.assertEqual(3, row_index)

    def test_list_all_samples_under_library_id_columns__entries_found(self):
        samples = self.excel_reader._samples
        self.assertEqual(11, len(samples))
        self.assertEqual('SE-402', samples[0])

    def test_validate(self):
        error_messages = self.excel_reader.check_faulty_contents()
        self.assertEqual(9, len(error_messages))
 def setUp(self):
     here = os.path.dirname(__file__)
     file_name = r'BLA-32605-v.4.0_Samples_for_library_preparation_SampleForm_test till validering.xlsx'
     file_path = os.path.join(here, file_name)
     sample_column_index = 4
     volume_column_index = 6
     sample_column_name = 'SAMPLE ID'
     here = os.path.dirname(__file__)
     export_file_path = os.path.join(here, 'newfile.xlsx')
     self.excel_reader = ImportSampleSubmission(file_path,
                                                sample_column_index,
                                                volume_column_index,
                                                sample_column_name,
                                                export_file_path)
 def setUp(self):
     here = os.path.dirname(__file__)
     file_name = r'BLA-32606-v.5.0_Ready-made-libraries_SampleForm.xlsx'
     file_path = os.path.join(here, file_name)
     sample_column_index = 3
     volume_column_index = 7
     sample_column_name = 'LIBRARY ID'
     here = os.path.dirname(__file__)
     export_file_path = os.path.join(here, 'newfile.xlsx')
     self.excel_reader = ImportSampleSubmission(file_path,
                                                sample_column_index,
                                                volume_column_index,
                                                sample_column_name,
                                                export_file_path)
class TestImportReadyMadeLibraries(unittest.TestCase):
    def setUp(self):
        here = os.path.dirname(__file__)
        file_name = r'BLA-32606-v.5.0_Ready-made-libraries_SampleForm.xlsx'
        file_path = os.path.join(here, file_name)
        sample_column_index = 3
        volume_column_index = 7
        sample_column_name = 'LIBRARY ID'
        here = os.path.dirname(__file__)
        export_file_path = os.path.join(here, 'newfile.xlsx')
        self.excel_reader = ImportSampleSubmission(file_path,
                                                   sample_column_index,
                                                   volume_column_index,
                                                   sample_column_name,
                                                   export_file_path)

    def test_get_caption_row(self):
        row_index = self.excel_reader._determine_caption_row_index()
        self.assertEqual(5, row_index)

    def test_list_all_samples_under_library_id_columns__three_entries_found(
            self):
        samples = self.excel_reader._samples
        self.assertEqual(3, len(samples))
        self.assertEqual('edvardsample', samples[0])

    def test_read_empty_volume_value__parsed_value_is_magic_str(self):
        contents = self.excel_reader.contents
        empty_volume = contents[1][1]
        self.assertEqual('None', empty_volume)

    def test_read_numeric_volume__parsed_value_is_str(self):
        contents = self.excel_reader.contents
        numeric_volume = contents[0][1]
        self.assertEqual('29', numeric_volume)
def validate(sample_column_index, volume_column_index, sample_column_name,
             file_path):
    logger = DefaultLogger()
    import_excel = ImportSampleSubmission(
        file_path, sample_column_index, volume_column_index,
        sample_column_name, logger=logger)
    error_messages = import_excel.check_faulty_contents()
    if len(error_messages) > 0:
        cache = PrintCache()
        cache.print('These rows were faulty:')
        for smp in error_messages:
            cache.print(smp)
        cache.copy_to_clipboard()
    else:
        print('No errors detected!')
    if not import_excel.save_workbook():
        print('Excel formatting cannot be updated because the file is already open. '
              'Please close the file if you want excel formatting enabled!')
class TestImportReadyMadeLibraries(unittest.TestCase):
    def setUp(self):
        here = os.path.dirname(__file__)
        file_name = r'BLA-32606-v.5.0_Ready-made-libraries_SampleForm.xlsx'
        file_path = os.path.join(here, file_name)
        export_path = os.path.join(here, 'newfile.xlsx')
        self.export_path = export_path
        sample_column_index = 3
        volume_column_index = 7
        sample_column_name = 'LIBRARY ID'
        self.excel_reader = ImportSampleSubmission(
            file_path,
            sample_column_index,
            volume_column_index,
            sample_column_name,
            export_to_file_path=export_path)

    def test_export(self):
        self.excel_reader.check_faulty_contents()
        print('NewFile.xlsx is updated to: \n{}'.format(self.export_path))
        self.assertEqual(1, 2)

    @skip('')
    def test_row_cols(self):
        number_rows = self.excel_reader.number_rows()
        number_cols = self.excel_reader.number_cols()
        print('rows: {}, cols: {}'.format(number_rows, number_cols))
        self.assertEqual(1, 2)

    @skip('')
    def test_print_sample_col(self):
        self.excel_reader.print_sample_column()
        self.assertEqual(1, 2)