<s> from unittest import TestCase <EOL> from openelex . lib import format_date , standardized_filename <EOL> from openelex . lib . text import ocd_type_id , election_slug <EOL> class TestText ( TestCase ) : <EOL> def test_ocd_type_id ( self ) : <EOL> self . assertEqual ( ocd_type_id ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" ) <EOL> self . assertEqual ( ocd_type_id ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" ) <EOL> self . assertEqual ( ocd_type_id ( "<STR_LIT>" , False ) , <EOL> u"<STR_LIT>" ) <EOL> self . assertEqual ( ocd_type_id ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" ) <EOL> self . assertEqual ( ocd_type_id ( "<STR_LIT>" , False ) , <EOL> u"<STR_LIT>" ) <EOL> def test_election_slug ( self ) : <EOL> elec_attrs = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:state>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:state>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:state>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> } <EOL> for slug , attrs in elec_attrs . items ( ) : <EOL> self . assertEqual ( election_slug ( ** attrs ) , slug ) <EOL> class TestLib ( TestCase ) : <EOL> def test_standardized_filename ( self ) : <EOL> kwargs = { <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT:state>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> } <EOL> expected = "<STR_LIT>" <EOL> filename = standardized_filename ( ** kwargs ) <EOL> self . assertEqual ( filename , expected ) <EOL> kwargs = { <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT:state>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> } <EOL> expected = "<STR_LIT>" <EOL> filename = standardized_filename ( ** kwargs ) <EOL> self . assertEqual ( filename , expected ) <EOL> kwargs = { <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT:state>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> expected = "<STR_LIT>" <EOL> filename = standardized_filename ( ** kwargs ) <EOL> self . assertEqual ( filename , expected ) <EOL> def test_format_date ( self ) : <EOL> test_values = [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ] <EOL> for input_date , expected in test_values : <EOL> self . assertEqual ( format_date ( input_date ) , expected ) <EOL> self . assertRaises ( ValueError , format_date , "<STR_LIT>" ) </s>
