PageRenderTime 94ms CodeModel.GetById 16ms app.highlight 72ms RepoModel.GetById 2ms app.codeStats 0ms

/test/functional/test_get_data.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 639 lines | 367 code | 118 blank | 154 comment | 38 complexity | dc27a6774ab8ce31c04b2474425282fb MD5 | raw file
  1from base.twilltestcase import TwillTestCase
  2from base.test_db_util import (
  3    get_user,
  4    get_latest_history_for_user,
  5    get_latest_hda,
  6)
  7
  8admin_user = None
  9
 10
 11class UploadData( TwillTestCase ):
 12
 13    def test_0000_setup_upload_tests( self ):
 14        """
 15        Configuring upload tests, setting admin_user
 16        """
 17        self.logout()
 18        self.login( email='test@bx.psu.edu' )
 19        global admin_user
 20        admin_user = get_user( email='test@bx.psu.edu' )
 21
 22    def create_fresh_history( self, user ):
 23        """
 24        Deletes latest history for the given user, checks for an empty history,
 25        and returns that new, empty history
 26        """
 27        # in order to remove a lot of boiler plate - and not have cascading errors
 28        history = get_latest_history_for_user( user )
 29        self.delete_history( id=self.security.encode_id( history.id ) )
 30        self.is_history_empty()
 31        return get_latest_history_for_user( user )
 32
 33    def test_0005_upload_file( self ):
 34        """
 35        Test uploading 1.bed, NOT setting the file format
 36        """
 37        history = self.create_fresh_history( admin_user )
 38
 39        self.upload_file( '1.bed' )
 40        hda = get_latest_hda()
 41        assert hda is not None, "Problem retrieving hda from database"
 42        self.verify_dataset_correctness( '1.bed', hid=str( hda.hid ) )
 43        self.check_history_for_string( "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>" )
 44
 45        self.delete_history( id=self.security.encode_id( history.id ) )
 46
 47    def test_0006_upload_file( self ):
 48        """
 49        Test uploading 1.bed.spaces, with space to tab selected, NOT setting the file format
 50        """
 51        history = self.create_fresh_history( admin_user )
 52
 53        self.upload_file( '1.bed.spaces', space_to_tab=True )
 54        hda = get_latest_hda()
 55        assert hda is not None, "Problem retrieving hda from database"
 56        self.verify_dataset_correctness( '1.bed', hid=str( hda.hid ) )
 57        self.check_history_for_string( "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>" )
 58
 59        self.delete_history( id=self.security.encode_id( history.id ) )
 60
 61    def test_0010_upload_file( self ):
 62        """
 63        Test uploading 4.bed.gz, manually setting the file format
 64        """
 65        history = self.create_fresh_history( admin_user )
 66
 67        self.upload_file( '4.bed.gz', dbkey='hg17', ftype='bed' )
 68        hda = get_latest_hda()
 69        assert hda is not None, "Problem retrieving hda from database"
 70        self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) )
 71        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
 72            "peek", "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>", use_string_contains=True )
 73
 74        self.delete_history( id=self.security.encode_id( history.id ) )
 75
 76    def test_0012_upload_file( self ):
 77        """
 78        Test uploading 4.bed.bz2, manually setting the file format
 79        """
 80        history = self.create_fresh_history( admin_user )
 81
 82        self.upload_file( '4.bed.bz2', dbkey='hg17', ftype='bed' )
 83        hda = get_latest_hda()
 84        assert hda is not None, "Problem retrieving hda from database"
 85
 86        self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) )
 87        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
 88            "peek", "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>", use_string_contains=True )
 89
 90        self.delete_history( id=self.security.encode_id( history.id ) )
 91
 92    def test_0015_upload_file( self ):
 93        """
 94        Test uploading 1.scf, manually setting the file format
 95        """
 96        history = self.create_fresh_history( admin_user )
 97
 98        self.upload_file( '1.scf', ftype='scf' )
 99        hda = get_latest_hda()
100        assert hda is not None, "Problem retrieving hda from database"
101        self.verify_dataset_correctness( '1.scf', hid=str( hda.hid ) )
102        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
103            "peek", "Binary scf sequence file", use_string_contains=True )
104
105        self.delete_history( id=self.security.encode_id( history.id ) )
106
107    def test_0020_upload_file( self ):
108        """
109        Test uploading 1.scf, NOT setting the file format
110        """
111        history = self.create_fresh_history( admin_user )
112
113        self.upload_file( '1.scf' )
114        hda = get_latest_hda()
115        assert hda is not None, "Problem retrieving hda from database"
116        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
117            "misc_info", "File Format' to 'Scf' when uploading scf files", use_string_contains=True )
118
119        self.delete_history( id=self.security.encode_id( history.id ) )
120
121    def test_0025_upload_file( self ):
122        """
123        Test uploading 4.bed.zip, manually setting the file format
124        """
125        history = self.create_fresh_history( admin_user )
126
127        self.upload_file( '4.bed.zip', ftype='bed' )
128        hda = get_latest_hda()
129        assert hda is not None, "Problem retrieving hda from database"
130        self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) )
131        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
132            "peek", "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>", use_string_contains=True )
133
134        self.delete_history( id=self.security.encode_id( history.id ) )
135
136    def test_0030_upload_file( self ):
137        """
138        Test uploading 4.bed.zip, NOT setting the file format
139        """
140        history = self.create_fresh_history( admin_user )
141
142        self.upload_file( '4.bed.zip' )
143        hda = get_latest_hda()
144        assert hda is not None, "Problem retrieving hda from database"
145        self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) )
146        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
147            "peek", "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>", use_string_contains=True )
148
149        self.delete_history( id=self.security.encode_id( history.id ) )
150
151    def test_0035_upload_file( self ):
152        """
153        Test uploading 1.sam NOT setting the file format
154        """
155        history = self.create_fresh_history( admin_user )
156
157        self.upload_file( '1.sam' )
158        hda = get_latest_hda()
159        assert hda is not None, "Problem retrieving hda from database"
160        self.verify_dataset_correctness( '1.sam', hid=str( hda.hid ) )
161        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
162            "peek", "<th>1.QNAME</th><th>2.FLAG</th><th>3.RNAME</th><th>4.POS</th>", use_string_contains=True )
163
164        self.delete_history( id=self.security.encode_id( history.id ) )
165
166    def test_0040_upload_file( self ):
167        """
168        Test uploading 1.sff, NOT setting the file format
169        """
170        history = self.create_fresh_history( admin_user )
171
172        self.upload_file( '1.sff' )
173        hda = get_latest_hda()
174        assert hda is not None, "Problem retrieving hda from database"
175        self.verify_dataset_correctness( '1.sff', hid=str( hda.hid ) )
176        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
177            "misc_info", "sff", use_string_contains=True )
178
179        self.delete_history( id=self.security.encode_id( history.id ) )
180
181    def test_0045_upload_file( self ):
182        """
183        Test uploading 454Score.pdf, NOT setting the file format
184        """
185        history = self.create_fresh_history( admin_user )
186
187        self.upload_file( '454Score.pdf' )
188        hda = get_latest_hda()
189        assert hda is not None, "Problem retrieving hda from database"
190        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
191            "name", "454Score.pdf" )
192
193        self.delete_history( id=self.security.encode_id( history.id ) )
194
195    def test_0050_upload_file( self ):
196        """
197        Test uploading 454Score.png, NOT setting the file format
198        """
199        history = self.create_fresh_history( admin_user )
200
201        self.upload_file( '454Score.png' )
202        hda = get_latest_hda()
203        assert hda is not None, "Problem retrieving hda from database"
204        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
205            "name", "454Score.png" )
206
207        self.delete_history( id=self.security.encode_id( history.id ) )
208
209    def test_0055_upload_file( self ):
210        """
211        Test uploading lped composite datatype file, manually setting the file format
212        """
213        # Logged in as admin_user
214        history = self.create_fresh_history( admin_user )
215
216        # lped data types include a ped_file and a map_file ( which is binary )
217        self.upload_file( None, ftype='lped', metadata=[ { 'name':'base_name', 'value':'rgenetics' } ], composite_data=[ { 'name':'ped_file', 'value':'tinywga.ped' }, { 'name':'map_file', 'value':'tinywga.map'} ] )
218        # Get the latest hid for testing
219        hda = get_latest_hda()
220        assert hda is not None, "Problem retrieving hda from database"
221        # We'll test against the resulting ped file and map file for correctness
222        self.verify_composite_datatype_file_content( 'tinywga.ped', str( hda.id ), base_name='rgenetics.ped' )
223        self.verify_composite_datatype_file_content( 'tinywga.map', str( hda.id ), base_name='rgenetics.map' )
224        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
225            "metadata_base_name", "rgenetics", use_string_contains=True )
226
227        self.delete_history( id=self.security.encode_id( history.id ) )
228
229    def test_0056_upload_file( self ):
230        """
231        Test uploading lped composite datatype file, manually setting the file format, and using space to tab on one file (tinywga.ped)
232        """
233        # Logged in as admin_user
234        history = self.create_fresh_history( admin_user )
235
236        # lped data types include a ped_file and a map_file ( which is binary )
237        self.upload_file( None, ftype='lped', metadata=[ { 'name':'base_name', 'value':'rgenetics' } ], composite_data=[ { 'name':'ped_file', 'value':'tinywga.ped', 'space_to_tab':True }, { 'name':'map_file', 'value':'tinywga.map'} ] )
238        # Get the latest hid for testing
239        hda = get_latest_hda()
240        assert hda is not None, "Problem retrieving hda from database"
241        # We'll test against the resulting ped file and map file for correctness
242        self.verify_composite_datatype_file_content( 'tinywga.ped.space_to_tab', str( hda.id ), base_name='rgenetics.ped' )
243        self.verify_composite_datatype_file_content( 'tinywga.map', str( hda.id ), base_name='rgenetics.map' )
244        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
245            "metadata_base_name", "rgenetics", use_string_contains=True )
246
247        self.delete_history( id=self.security.encode_id( history.id ) )
248
249    def test_0060_upload_file( self ):
250        """
251        Test uploading pbed composite datatype file, manually setting the file format
252        """
253        # Logged in as admin_user
254        history = self.create_fresh_history( admin_user )
255
256        # pbed data types include a bim_file, a bed_file and a fam_file
257        self.upload_file( None, ftype='pbed',
258            metadata=[ { 'name':'base_name', 'value':'rgenetics' } ],
259            composite_data=[
260                { 'name':'bim_file', 'value':'tinywga.bim' },
261                { 'name':'bed_file', 'value':'tinywga.bed' },
262                { 'name':'fam_file', 'value':'tinywga.fam' } ])
263        # Get the latest hid for testing
264        hda = get_latest_hda()
265        assert hda is not None, "Problem retrieving hda from database"
266        # We'll test against the resulting ped file and map file for correctness
267        self.verify_composite_datatype_file_content( 'tinywga.bim', str( hda.id ), base_name='rgenetics.bim' )
268        self.verify_composite_datatype_file_content( 'tinywga.bed', str( hda.id ), base_name='rgenetics.bed' )
269        self.verify_composite_datatype_file_content( 'tinywga.fam', str( hda.id ), base_name='rgenetics.fam' )
270        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
271            "metadata_base_name", "rgenetics", use_string_contains=True )
272
273        self.delete_history( id=self.security.encode_id( history.id ) )
274
275    def test_0065_upload_file( self ):
276        """
277        Test uploading asian_chars_1.txt, NOT setting the file format
278        """
279        # Logged in as admin_user
280        history = self.create_fresh_history( admin_user )
281
282        self.upload_file( 'asian_chars_1.txt' )
283        hda = get_latest_hda()
284        assert hda is not None, "Problem retrieving hda from database"
285        self.verify_dataset_correctness( 'asian_chars_1.txt', hid=str( hda.hid ) )
286        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
287            "misc_info", "uploaded multi-byte char file", use_string_contains=True )
288
289        self.delete_history( id=self.security.encode_id( history.id ) )
290
291    def test_0070_upload_file( self ):
292        """
293        Test uploading 2gen.fastq, NOT setting the file format
294        """
295        # Logged in as admin_user
296        history = self.create_fresh_history( admin_user )
297
298        self.upload_file( '2gen.fastq' )
299        hda = get_latest_hda()
300        assert hda is not None, "Problem retrieving hda from database"
301        self.verify_dataset_correctness( '2gen.fastq', hid=str( hda.hid ) )
302        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "fastq" )
303
304        self.delete_history( id=self.security.encode_id( history.id ) )
305
306    def test_0075_upload_file( self ):
307        """
308        Test uploading 1.wig, NOT setting the file format
309        """
310        # Logged in as admin_user
311        history = self.create_fresh_history( admin_user )
312
313        self.upload_file( '1.wig' )
314        hda = get_latest_hda()
315        assert hda is not None, "Problem retrieving hda from database"
316        self.verify_dataset_correctness( '1.wig', hid=str( hda.hid ) )
317        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "wig" )
318        self.check_metadata_for_string( 'value="1.wig" value="\?"' )
319        self.check_metadata_for_string( 'Change data type selected value="wig" selected="yes"' )
320
321        self.delete_history( id=self.security.encode_id( history.id ) )
322
323    def test_0080_upload_file( self ):
324        """
325        Test uploading 1.tabular, NOT setting the file format
326        """
327        # Logged in as admin_user
328        history = self.create_fresh_history( admin_user )
329
330        self.upload_file( '1.tabular' )
331        hda = get_latest_hda()
332        assert hda is not None, "Problem retrieving hda from database"
333        self.verify_dataset_correctness( '1.tabular', hid=str( hda.hid ) )
334        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "tabular" )
335        self.check_metadata_for_string( 'value="1.tabular" value="\?"' )
336        self.check_metadata_for_string( 'Change data type selected value="tabular" selected="yes"' )
337
338        self.delete_history( id=self.security.encode_id( history.id ) )
339
340    def test_0085_upload_file( self ):
341        """
342        Test uploading qualscores.qualsolid, NOT setting the file format
343        """
344        # Logged in as admin_user
345        history = self.create_fresh_history( admin_user )
346
347        self.upload_file( 'qualscores.qualsolid' )
348        hda = get_latest_hda()
349        assert hda is not None, "Problem retrieving hda from database"
350        self.verify_dataset_correctness( 'qualscores.qualsolid', hid=str( hda.hid ) )
351        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "qualsolid" )
352        self.check_metadata_for_string( 'Change data type value="qualsolid" selected="yes">qualsolid' )
353
354        self.delete_history( id=self.security.encode_id( history.id ) )
355
356    def test_0090_upload_file( self ):
357        """
358        Test uploading qualscores.qual454, NOT setting the file format
359        """
360        # Logged in as admin_user
361        history = self.create_fresh_history( admin_user )
362
363        self.upload_file( 'qualscores.qual454' )
364        hda = get_latest_hda()
365        assert hda is not None, "Problem retrieving hda from database"
366        self.verify_dataset_correctness( 'qualscores.qual454', hid=str( hda.hid ) )
367        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "qual454" )
368        self.check_metadata_for_string( 'Change data type value="qual454" selected="yes">qual454' )
369
370        self.delete_history( id=self.security.encode_id( history.id ) )
371
372    def test_0095_upload_file( self ):
373        """
374        Test uploading 3.maf, NOT setting the file format
375        """
376        # Logged in as admin_user
377        history = self.create_fresh_history( admin_user )
378
379        self.upload_file( '3.maf' )
380        hda = get_latest_hda()
381        assert hda is not None, "Problem retrieving hda from database"
382        self.verify_dataset_correctness( '3.maf', hid=str( hda.hid ) )
383        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "maf" )
384        self.check_metadata_for_string( 'value="3.maf" value="\?"' )
385        self.check_metadata_for_string( 'Convert to new format <option value="interval">Convert MAF to Genomic Intervals <option value="fasta">Convert MAF to Fasta' )
386        self.check_metadata_for_string( 'Change data type selected value="maf" selected="yes"' )
387
388        self.delete_history( id=self.security.encode_id( history.id ) )
389
390    def test_0100_upload_file( self ):
391        """
392        Test uploading 1.lav, NOT setting the file format
393        """
394        # Logged in as admin_user
395        history = self.create_fresh_history( admin_user )
396
397        self.upload_file( '1.lav' )
398        hda = get_latest_hda()
399        assert hda is not None, "Problem retrieving hda from database"
400        self.verify_dataset_correctness( '1.lav', hid=str( hda.hid ) )
401        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "lav" )
402        self.check_metadata_for_string( 'value="1.lav" value="\?"' )
403        self.check_metadata_for_string( 'Change data type selected value="lav" selected="yes"' )
404
405        self.delete_history( id=self.security.encode_id( history.id ) )
406
407    def test_0105_upload_file( self ):
408        """
409        Test uploading 1.interval, NOT setting the file format
410        """
411        # Logged in as admin_user
412        history = self.create_fresh_history( admin_user )
413
414        self.upload_file( '1.interval' )
415        hda = get_latest_hda()
416        assert hda is not None, "Problem retrieving hda from database"
417        self.verify_dataset_correctness( '1.interval', hid=str( hda.hid ) )
418        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "interval" )
419        self.check_metadata_for_string( 'value="1.interval" value="\?"' )
420        self.check_metadata_for_string( 'Chrom column: <option value="1" selected> Start column: <option value="2" selected>' )
421        self.check_metadata_for_string( 'End column: <option value="3" selected> Strand column <option value="6" selected>' )
422        self.check_metadata_for_string( 'Convert to new format <option value="bed">Convert Genomic Intervals To BED' )
423        self.check_metadata_for_string( 'Change data type selected value="interval" selected="yes"' )
424
425        self.delete_history( id=self.security.encode_id( history.id ) )
426
427    def test_0110_upload_file( self ):
428        """
429        Test uploading 5.gff3, NOT setting the file format
430        """
431        # Logged in as admin_user
432        history = self.create_fresh_history( admin_user )
433
434        self.upload_file( '5.gff3' )
435        hda = get_latest_hda()
436        assert hda is not None, "Problem retrieving hda from database"
437        self.verify_dataset_correctness( '5.gff3', hid=str( hda.hid ) )
438        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "gff3" )
439        self.check_metadata_for_string( 'value="5.gff3" value="\?"' )
440        self.check_metadata_for_string( 'Convert to new format <option value="bed">Convert GFF to BED' )
441        self.check_metadata_for_string( 'Change data type selected value="gff3" selected="yes"' )
442
443        self.delete_history( id=self.security.encode_id( history.id ) )
444
445    def test_0115_upload_file( self ):
446        """
447        Test uploading html_file.txt, NOT setting the file format
448        """
449        # Logged in as admin_user
450        history = self.create_fresh_history( admin_user )
451
452        self.upload_file( 'html_file.txt' )
453        hda = get_latest_hda()
454        assert hda is not None, "Problem retrieving hda from database"
455        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
456            "misc_info", "The uploaded file contains inappropriate HTML content", use_string_contains=True )
457
458        self.delete_history( id=self.security.encode_id( history.id ) )
459
460    def test_0120_upload_file( self ):
461        """
462        Test uploading 5.gff, NOT setting the file format
463
464        Test sniffer for gff.
465        """
466        history = self.create_fresh_history( admin_user )
467
468        self.upload_file( '5.gff' )
469        hda = get_latest_hda()
470        assert hda is not None, "Problem retrieving hda from database"
471        self.verify_dataset_correctness( '5.gff', hid=str( hda.hid ) )
472        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "gff" )
473        self.check_metadata_for_string( 'value="5.gff" value="\?"' )
474        self.check_metadata_for_string( 'Convert to new format <option value="bed">Convert GFF to BED' )
475        self.check_metadata_for_string( 'Change data type selected value="gff" selected="yes"' )
476
477        self.delete_history( id=self.security.encode_id( history.id ) )
478
479    def test_0125_upload_file( self ):
480        """
481        Test uploading 1.fasta, NOT setting the file format
482        """
483        # Logged in as admin_user
484        history = self.create_fresh_history( admin_user )
485
486        self.upload_file( '1.fasta' )
487        hda = get_latest_hda()
488        assert hda is not None, "Problem retrieving hda from database"
489        self.verify_dataset_correctness( '1.fasta', hid=str( hda.hid ) )
490        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "fasta" )
491        self.check_metadata_for_string( 'value="1.fasta" value="\?" Change data type selected value="fasta" selected="yes"' )
492
493        self.delete_history( id=self.security.encode_id( history.id ) )
494
495    def test_0130_upload_file( self ):
496        """
497        Test uploading 1.customtrack, NOT setting the file format
498        """
499        # Logged in as admin_user
500        history = self.create_fresh_history( admin_user )
501
502        self.upload_file( '1.customtrack' )
503        hda = get_latest_hda()
504        assert hda is not None, "Problem retrieving hda from database"
505        self.verify_dataset_correctness( '1.customtrack', hid=str( hda.hid ) )
506        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "customtrack" )
507        self.check_metadata_for_string( 'value="1.customtrack" value="\?" Change data type selected value="customtrack" selected="yes"' )
508
509        self.delete_history( id=self.security.encode_id( history.id ) )
510
511    def test_0135_upload_file( self ):
512        """
513        Test uploading shrimp_cs_test1.csfasta, NOT setting the file format
514        """
515        # Logged in as admin_user
516        history = self.create_fresh_history( admin_user )
517
518        self.upload_file( 'shrimp_cs_test1.csfasta' )
519        hda = get_latest_hda()
520        assert hda is not None, "Problem retrieving hda from database"
521        self.verify_dataset_correctness( 'shrimp_cs_test1.csfasta', hid=str( hda.hid ) )
522        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "csfasta" )
523        self.check_metadata_for_string( 'value="shrimp_cs_test1.csfasta" value="\?" Change data type value="csfasta" selected="yes"' )
524
525        self.delete_history( id=self.security.encode_id( history.id ) )
526
527    def test_0145_upload_file( self ):
528        """
529        Test uploading 1.axt, NOT setting the file format
530        """
531        # Logged in as admin_user
532        history = self.create_fresh_history( admin_user )
533
534        self.upload_file( '1.axt' )
535        hda = get_latest_hda()
536        assert hda is not None, "Problem retrieving hda from database"
537        self.verify_dataset_correctness( '1.axt', hid=str( hda.hid ) )
538        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "axt" )
539        self.check_metadata_for_string( 'value="1.axt" value="\?" Change data type selected value="axt" selected="yes"' )
540
541        self.delete_history( id=self.security.encode_id( history.id ) )
542
543    def test_0150_upload_file( self ):
544        """
545        Test uploading 1.bam, which is a sorted Bam file creaed by the Galaxy sam_to_bam tool, NOT setting the file format
546        """
547        history = self.create_fresh_history( admin_user )
548
549        self.upload_file( '1.bam' )
550        hda = get_latest_hda()
551        assert hda is not None, "Problem retrieving hda from database"
552        self.verify_dataset_correctness( '1.bam', hid=str( hda.hid ), attributes={ 'ftype' : 'bam' } )
553        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "bam" )
554        # Make sure the Bam index was created
555        assert hda.metadata.bam_index is not None, "Bam index was not correctly created for 1.bam"
556
557        self.delete_history( id=self.security.encode_id( history.id ) )
558
559    def test_0155_upload_file( self ):
560        """
561        Test uploading 3unsorted.bam, which is an unsorted Bam file, NOT setting the file format
562        """
563        history = self.create_fresh_history( admin_user )
564
565        self.upload_file( '3unsorted.bam' )
566        hda = get_latest_hda()
567        assert hda is not None, "Problem retrieving hda from database"
568        # Since 3unsorted.bam is not sorted, we cannot verify dataset correctness since the uploaded
569        # dataset will be sorted.  However, the check below to see if the index was created is
570        # sufficient.
571        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "bam" )
572        # Make sure the Bam index was created
573        assert hda.metadata.bam_index is not None, "Bam index was not correctly created for 3unsorted.bam"
574
575        self.delete_history( id=self.security.encode_id( history.id ) )
576
577    def test_0160_url_paste( self ):
578        """
579        Test url paste behavior
580        """
581        # Logged in as admin_user
582        history = self.create_fresh_history( admin_user )
583
584        self.upload_url_paste( 'hello world' )
585        self.check_history_for_exact_string( 'Pasted Entry' )
586        self.check_history_for_exact_string( 'hello world' )
587        self.upload_url_paste( u'hello world' )
588        self.check_history_for_exact_string( 'Pasted Entry' )
589        self.check_history_for_exact_string( 'hello world' )
590
591        self.delete_history( id=self.security.encode_id( history.id ) )
592
593    def test_0165_upload_file( self ):
594        """
595        Test uploading 1.pileup, NOT setting the file format
596        """
597        history = self.create_fresh_history( admin_user )
598
599        self.upload_file( '1.pileup' )
600        hda = get_latest_hda()
601        assert hda is not None, "Problem retrieving hda from database"
602        self.verify_dataset_correctness( '1.pileup', hid=str( hda.hid ) )
603        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "pileup" )
604        self.check_metadata_for_string( 'value="1.pileup" value="\?" Change data type selected value="pileup" selected="yes"' )
605
606        self.delete_history( id=self.security.encode_id( history.id ) )
607
608    def test_0170_upload_file( self ):
609        """
610        Test uploading 1.bigbed, NOT setting the file format
611        """
612        history = self.create_fresh_history( admin_user )
613
614        self.upload_file( '1.bigbed' )
615        hda = get_latest_hda()
616        assert hda is not None, "Problem retrieving hda from database"
617        self.verify_dataset_correctness( '1.bigbed', hid=str( hda.hid ) )
618        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "bigbed" )
619        self.check_metadata_for_string( 'value="1.bigbed" value="\?" Change data type selected value="bigbed" selected="yes"' )
620
621        self.delete_history( id=self.security.encode_id( history.id ) )
622
623    def test_0175_upload_file( self ):
624        """
625        Test uploading 1.bigwig, NOT setting the file format
626        """
627        history = self.create_fresh_history( admin_user )
628
629        self.upload_file( '1.bigwig' )
630        hda = get_latest_hda()
631        assert hda is not None, "Problem retrieving hda from database"
632        self.verify_dataset_correctness( '1.bigwig', hid=str( hda.hid ) )
633        self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "bigwig" )
634        self.check_metadata_for_string( 'value="1.bigwig" value="\?" Change data type selected value="bigwig" selected="yes"' )
635
636        self.delete_history( id=self.security.encode_id( history.id ) )
637
638    def test_9999_clean_up( self ):
639        self.logout()