19
19
from qiita_core .util import qiita_test_checker
20
20
from qiita_core .exceptions import IncompetentQiitaDeveloperError
21
21
from qiita_db .exceptions import (QiitaDBDuplicateError , QiitaDBUnknownIDError ,
22
- QiitaDBNotImplementedError )
22
+ QiitaDBNotImplementedError ,
23
+ QiitaDBDuplicateHeaderError )
23
24
from qiita_db .study import Study , StudyPerson
24
25
from qiita_db .user import User
25
26
from qiita_db .data import RawData
@@ -481,7 +482,7 @@ def setUp(self):
481
482
'collection_timestamp' :
482
483
datetime (2014 , 5 , 29 , 12 , 24 , 51 ),
483
484
'host_subject_id' : 'NotIdentified' ,
484
- 'description ' : 'Test Sample 1' ,
485
+ 'Description ' : 'Test Sample 1' ,
485
486
'str_column' : 'Value for sample 1' },
486
487
'Sample2' : {'physical_location' : 'location1' ,
487
488
'has_physical_specimen' : True ,
@@ -491,7 +492,7 @@ def setUp(self):
491
492
'collection_timestamp' :
492
493
datetime (2014 , 5 , 29 , 12 , 24 , 51 ),
493
494
'host_subject_id' : 'NotIdentified' ,
494
- 'description ' : 'Test Sample 2' ,
495
+ 'Description ' : 'Test Sample 2' ,
495
496
'str_column' : 'Value for sample 2' },
496
497
'Sample3' : {'physical_location' : 'location1' ,
497
498
'has_physical_specimen' : True ,
@@ -501,7 +502,7 @@ def setUp(self):
501
502
'collection_timestamp' :
502
503
datetime (2014 , 5 , 29 , 12 , 24 , 51 ),
503
504
'host_subject_id' : 'NotIdentified' ,
504
- 'description ' : 'Test Sample 3' ,
505
+ 'Description ' : 'Test Sample 3' ,
505
506
'str_column' : 'Value for sample 3' }
506
507
}
507
508
self .metadata = pd .DataFrame .from_dict (metadata_dict , orient = 'index' )
@@ -556,7 +557,14 @@ def test_create_duplicate(self):
556
557
with self .assertRaises (QiitaDBDuplicateError ):
557
558
SampleTemplate .create (self .metadata , self .test_study )
558
559
559
- def test_create_ (self ):
560
+ def test_create_duplicate_header (self ):
561
+ """Create raises an error when duplicate headers are present"""
562
+ self .metadata ['STR_COLUMN' ] = pd .Series (['' , '' , '' ],
563
+ index = self .metadata .index )
564
+ with self .assertRaises (QiitaDBDuplicateHeaderError ):
565
+ SampleTemplate .create (self .metadata , self .new_study )
566
+
567
+ def test_create (self ):
560
568
"""Creates a new SampleTemplate"""
561
569
st = SampleTemplate .create (self .metadata , self .new_study )
562
570
# The returned object has the correct id
@@ -750,21 +758,21 @@ def setUp(self):
750
758
'center_project_name' : 'Test Project' ,
751
759
'ebi_submission_accession' : None ,
752
760
'ebi_study_accession' : None ,
753
- 'emp_status_id ' : 1 ,
761
+ 'EMP_status_id ' : 1 ,
754
762
'data_type_id' : 2 ,
755
763
'str_column' : 'Value for sample 1' },
756
764
'SKD8.640184' : {'center_name' : 'ANL' ,
757
765
'center_project_name' : 'Test Project' ,
758
766
'ebi_submission_accession' : None ,
759
767
'ebi_study_accession' : None ,
760
- 'emp_status_id ' : 1 ,
768
+ 'EMP_status_id ' : 1 ,
761
769
'data_type_id' : 2 ,
762
770
'str_column' : 'Value for sample 2' },
763
771
'SKB7.640196' : {'center_name' : 'ANL' ,
764
772
'center_project_name' : 'Test Project' ,
765
773
'ebi_submission_accession' : None ,
766
774
'ebi_study_accession' : None ,
767
- 'emp_status_id ' : 1 ,
775
+ 'EMP_status_id ' : 1 ,
768
776
'data_type_id' : 2 ,
769
777
'str_column' : 'Value for sample 3' }
770
778
}
@@ -822,6 +830,13 @@ def test_create_duplicate(self):
822
830
with self .assertRaises (QiitaDBDuplicateError ):
823
831
PrepTemplate .create (self .metadata , self .test_raw_data )
824
832
833
+ def test_create_duplicate_header (self ):
834
+ """Create raises an error when duplicate headers are present"""
835
+ self .metadata ['STR_COLUMN' ] = pd .Series (['' , '' , '' ],
836
+ index = self .metadata .index )
837
+ with self .assertRaises (QiitaDBDuplicateHeaderError ):
838
+ PrepTemplate .create (self .metadata , self .new_raw_data )
839
+
825
840
def test_create (self ):
826
841
"""Creates a new PrepTemplate"""
827
842
pt = PrepTemplate .create (self .metadata , self .new_raw_data )
0 commit comments