<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from __future__ import print_function <EOL> from __future__ import unicode_literals <EOL> import unittest <EOL> import ga4gh . datamodel as datamodel <EOL> import ga4gh . exceptions as exceptions <EOL> class TestPysamSanitizer ( datamodel . PysamDatamodelMixin , unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def testSanitizeString ( self ) : <EOL> with self . assertRaises ( exceptions . DatamodelValidationException ) : <EOL> self . sanitizeString ( <NUM_LIT:1> , '<STR_LIT>' ) <EOL> shortString = '<STR_LIT>' <EOL> self . assertIsInstance ( shortString , unicode ) <EOL> result = self . sanitizeString ( shortString , shortString ) <EOL> self . assertEqual ( shortString , result ) <EOL> self . assertNotIsInstance ( result , unicode ) <EOL> longString = '<STR_LIT:x>' * ( self . maxStringLength + <NUM_LIT:1> ) <EOL> result = self . sanitizeString ( longString , '<STR_LIT>' ) <EOL> self . assertEqual ( longString [ : self . maxStringLength ] , result ) <EOL> def testSanitizeInt ( self ) : <EOL> with self . assertRaises ( exceptions . DatamodelValidationException ) : <EOL> self . sanitizeInt ( '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> minVal = <NUM_LIT:0> <EOL> result = self . sanitizeInt ( - <NUM_LIT:10> , minVal , <NUM_LIT:100> , '<STR_LIT:int>' ) <EOL> self . assertEqual ( minVal , result ) <EOL> maxVal = <NUM_LIT:100> <EOL> result = self . sanitizeInt ( <NUM_LIT:200> , <NUM_LIT:0> , maxVal , '<STR_LIT:int>' ) <EOL> self . assertEqual ( maxVal , result ) <EOL> val = <NUM_LIT:50> <EOL> result = self . sanitizeInt ( val , <NUM_LIT:0> , <NUM_LIT:100> , '<STR_LIT:int>' ) <EOL> self . assertEqual ( result , val ) <EOL> def testAssertValidRange ( self ) : <EOL> with self . assertRaises ( exceptions . DatamodelValidationException ) : <EOL> self . assertValidRange ( <NUM_LIT:100> , <NUM_LIT:0> , '<STR_LIT:start>' , '<STR_LIT:end>' ) <EOL> self . assertValidRange ( <NUM_LIT:0> , <NUM_LIT:100> , '<STR_LIT:start>' , '<STR_LIT:end>' ) <EOL> def testAssertInRange ( self ) : <EOL> with self . assertRaises ( exceptions . DatamodelValidationException ) : <EOL> self . assertInRange ( - <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:100> , '<STR_LIT>' ) <EOL> with self . assertRaises ( exceptions . DatamodelValidationException ) : <EOL> self . assertInRange ( <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:100> , '<STR_LIT>' ) <EOL> self . assertInRange ( <NUM_LIT:50> , <NUM_LIT:0> , <NUM_LIT:100> , '<STR_LIT>' ) <EOL> def testAssertInt ( self ) : <EOL> self . assertInt ( <NUM_LIT:5> , '<STR_LIT>' ) <EOL> with self . assertRaises ( exceptions . DatamodelValidationException ) : <EOL> self . assertInt ( '<STR_LIT:5>' , '<STR_LIT>' ) <EOL> def testSanitizeVariantFileFetch ( self ) : <EOL> contigArg = '<STR_LIT:x>' * ( self . maxStringLength + <NUM_LIT:1> ) <EOL> startArg = self . vcfMin - <NUM_LIT:1> <EOL> stopArg = self . vcfMax + <NUM_LIT:1> <EOL> contig , start , stop = self . sanitizeVariantFileFetch ( <EOL> contigArg , startArg , stopArg ) <EOL> self . assertEqual ( contigArg [ : self . maxStringLength ] , contig ) <EOL> self . assertEqual ( start , self . vcfMin ) <EOL> self . assertEqual ( stop , self . vcfMax ) <EOL> def testSanitizeAlignmentFileFetch ( self ) : <EOL> startArg = self . samMin - <NUM_LIT:1> <EOL> endArg = self . samMaxEnd + <NUM_LIT:1> <EOL> start , end = self . sanitizeAlignmentFileFetch ( startArg , endArg ) <EOL> self . assertEqual ( start , self . samMin ) <EOL> self . assertEqual ( end , self . samMaxEnd ) </s>
