<s> import unittest <EOL> from lib . filter import Filters <EOL> class TestDOI ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . valid_doi = "<STR_LIT>" <EOL> self . valid_doi_with_protocol = "<STR_LIT>" <EOL> self . invalid_doi = "<STR_LIT>" <EOL> self . valid_doi_organization = "<STR_LIT>" <EOL> def test_add_valid_doi_filter ( self ) : <EOL> f = Filters ( ) <EOL> try : <EOL> f . add ( '<STR_LIT>' , self . valid_doi ) <EOL> except Exception : <EOL> self . fail ( "<STR_LIT>" ) <EOL> self . assertEqual ( f . get_formatted_filters ( ) , "<STR_LIT>" ) <EOL> def test_add_invalid_doi_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertRaises ( ValueError , f . add , '<STR_LIT>' , self . invalid_doi ) <EOL> def _test_valid_date_filter ( self , filtername , date , awaited_result ) : <EOL> f = Filters ( ) <EOL> try : <EOL> f . add ( filtername , date ) <EOL> except Exception : <EOL> self . fail ( "<STR_LIT>" . format ( filtername ) ) <EOL> self . assertEqual ( f . get_formatted_filters ( ) , awaited_result ) <EOL> def test_add_valid_from_pub_date_filter ( self ) : <EOL> for date in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . _test_valid_date_filter ( '<STR_LIT>' , date , <EOL> "<STR_LIT>" . format ( '<STR_LIT>' , date ) ) <EOL> def test_add_invalid_from_pub_date_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertRaises ( ValueError , f . add , '<STR_LIT>' , "<STR_LIT>" ) <EOL> def test_add_valid_from_index_date_filter ( self ) : <EOL> for date in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . _test_valid_date_filter ( '<STR_LIT>' , date , <EOL> "<STR_LIT>" . format ( '<STR_LIT>' , date ) ) <EOL> def test_add_invalid_from_index_date_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertRaises ( ValueError , f . add , '<STR_LIT>' , "<STR_LIT>" ) <EOL> def test_add_valid_until_index_date_filter ( self ) : <EOL> for date in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . _test_valid_date_filter ( '<STR_LIT>' , date , <EOL> "<STR_LIT>" . format ( '<STR_LIT>' , date ) ) <EOL> def test_add_invalid_until_index_date_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertRaises ( ValueError , f . add , '<STR_LIT>' , "<STR_LIT>" ) <EOL> def test_add_valid_from_deposition_date_filter ( self ) : <EOL> for date in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . _test_valid_date_filter ( '<STR_LIT>' , date , <EOL> "<STR_LIT>" . format ( '<STR_LIT>' , date ) ) <EOL> def test_add_invalid_from_deposition_date_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertRaises ( ValueError , f . add , '<STR_LIT>' , "<STR_LIT>" ) <EOL> def test_add_valid_until_deposition_date_filter ( self ) : <EOL> for date in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . _test_valid_date_filter ( '<STR_LIT>' , date , <EOL> "<STR_LIT>" . format ( '<STR_LIT>' , date ) ) <EOL> def test_add_invalid_until_deposition_date_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertRaises ( ValueError , f . add , '<STR_LIT>' , "<STR_LIT>" ) <EOL> def test_add_valid_has_funder_filter ( self ) : <EOL> f = Filters ( ) <EOL> try : <EOL> f . add ( '<STR_LIT>' , True ) <EOL> except Exception : <EOL> self . fail ( "<STR_LIT>" ) <EOL> self . assertEqual ( f . get_formatted_filters ( ) . lower ( ) , <EOL> "<STR_LIT>" . lower ( ) ) <EOL> def test_add_invalid_has_funder_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertRaises ( ValueError , f . add , '<STR_LIT>' , "<STR_LIT:true>" ) <EOL> def test_add_valid_license_url_filter ( self ) : <EOL> f = Filters ( ) <EOL> try : <EOL> f . add ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_add_invalid_license_url_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertRaises ( ValueError , f . add , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def test_add_valid_full_text_version_filter ( self ) : <EOL> f = Filters ( ) <EOL> try : <EOL> f . add ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_add_invalid_full_text_version_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertRaises ( ValueError , f . add , '<STR_LIT>' , <NUM_LIT:4> ) <EOL> def test_empty_filter ( self ) : <EOL> f = Filters ( ) <EOL> self . assertEqual ( f . get_formatted_filters ( ) , "<STR_LIT>" ) <EOL> def test_multiple_filter_entries ( self ) : <EOL> f = Filters ( ) <EOL> f . add ( '<STR_LIT>' , self . valid_doi ) <EOL> f . add ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> for entry in f . get_formatted_filters ( ) . split ( '<STR_LIT:U+002C>' ) : <EOL> self . assertIn ( entry , [ "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
