<s> from unittest import TestCase , TestSuite , main , makeSuite <EOL> from fakeclient import FakeClient , GranularityFakeClient , TestError <EOL> import os <EOL> from datetime import datetime <EOL> from oaipmh import common , metadata , validation <EOL> directory = os . path . dirname ( __file__ ) <EOL> fake1 = os . path . join ( directory , '<STR_LIT>' ) <EOL> fakeclient = FakeClient ( fake1 ) <EOL> fakeclient . getMetadataRegistry ( ) . registerReader ( <EOL> '<STR_LIT>' , metadata . oai_dc_reader ) <EOL> class ClientTestCase ( TestCase ) : <EOL> def test_getRecord ( self ) : <EOL> header , metadata , about = fakeclient . getRecord ( <EOL> metadataPrefix = '<STR_LIT>' , identifier = '<STR_LIT>' ) <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> header . identifier ( ) ) <EOL> self . assertEquals ( <EOL> [ '<STR_LIT>' ] , <EOL> header . setSpec ( ) ) <EOL> self . assert_ ( not header . isDeleted ( ) ) <EOL> def test_getMetadata ( self ) : <EOL> metadata = fakeclient . getMetadata ( <EOL> metadataPrefix = '<STR_LIT>' , identifier = '<STR_LIT>' ) <EOL> self . assertEquals ( metadata . tag , <EOL> '<STR_LIT>' ) <EOL> def test_identify ( self ) : <EOL> identify = fakeclient . identify ( ) <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> identify . repositoryName ( ) ) <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> identify . baseURL ( ) ) <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> identify . protocolVersion ( ) ) <EOL> self . assertEquals ( <EOL> [ '<STR_LIT>' ] , <EOL> identify . adminEmails ( ) ) <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> identify . deletedRecord ( ) ) <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> identify . granularity ( ) ) <EOL> self . assertEquals ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> identify . compression ( ) ) <EOL> def test_listIdentifiers ( self ) : <EOL> headers = fakeclient . listIdentifiers ( from_ = datetime ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:4> , <NUM_LIT:10> ) , <EOL> metadataPrefix = '<STR_LIT>' ) <EOL> headers = list ( headers ) <EOL> header = headers [ <NUM_LIT:0> ] <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> header . identifier ( ) ) <EOL> self . assertEquals ( <EOL> datetime ( <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:15> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> ) , <EOL> header . datestamp ( ) ) <EOL> self . assertEquals ( <EOL> [ '<STR_LIT>' ] , <EOL> header . setSpec ( ) ) <EOL> self . assert_ ( not header . isDeleted ( ) ) <EOL> self . assertEquals ( <NUM_LIT:16> , len ( headers ) ) <EOL> def test_listIdentifiers_until_none ( self ) : <EOL> headers = fakeclient . listIdentifiers ( from_ = datetime ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:4> , <NUM_LIT:10> ) , <EOL> until = None , <EOL> metadataPrefix = '<STR_LIT>' ) <EOL> self . assertEquals ( <NUM_LIT:16> , len ( list ( headers ) ) ) <EOL> def test_listIdentifiers_from_none ( self ) : <EOL> try : <EOL> headers = fakeclient . listIdentifiers ( from_ = None , <EOL> metadataPrefix = '<STR_LIT>' ) <EOL> except KeyError , e : <EOL> self . assertEquals ( '<STR_LIT>' , <EOL> e . args [ <NUM_LIT:0> ] ) <EOL> def test_listIdentifiers_argument_error ( self ) : <EOL> self . assertRaises ( <EOL> validation . BadArgumentError , <EOL> fakeclient . listIdentifiers , <EOL> foo = '<STR_LIT:bar>' ) <EOL> def test_listRecords ( self ) : <EOL> records = fakeclient . listRecords ( from_ = datetime ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:4> , <NUM_LIT:10> ) , <EOL> metadataPrefix = '<STR_LIT>' ) <EOL> records = list ( records ) <EOL> header , metadata , about = records [ <NUM_LIT:0> ] <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> header . identifier ( ) ) <EOL> self . assertEquals ( <EOL> datetime ( <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:15> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> ) , <EOL> header . datestamp ( ) ) <EOL> self . assertEquals ( <EOL> [ '<STR_LIT>' ] , <EOL> header . setSpec ( ) ) <EOL> self . assert_ ( not header . isDeleted ( ) ) <EOL> self . assertEquals ( <EOL> [ '<STR_LIT>' ] , <EOL> metadata . getField ( '<STR_LIT:title>' ) ) <EOL> def test_listMetadataFormats ( self ) : <EOL> formats = fakeclient . listMetadataFormats ( ) <EOL> metadataPrefix , schema , metadataNamespace = formats [ <NUM_LIT:0> ] <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> metadataPrefix ) <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> schema ) <EOL> self . assertEquals ( <EOL> '<STR_LIT>' , <EOL> metadataNamespace ) <EOL> def test_listSets ( self ) : <EOL> expected = [ <EOL> ( '<STR_LIT:3>' , '<STR_LIT>' , None ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , None ) , <EOL> ] <EOL> sets = fakeclient . listSets ( ) <EOL> sets = list ( sets ) <EOL> compare = [ sets [ <NUM_LIT:0> ] , sets [ <NUM_LIT:1> ] ] <EOL> self . assertEquals ( <EOL> expected , <EOL> compare ) <EOL> def test_day_granularity ( self ) : <EOL> fakeclient = GranularityFakeClient ( granularity = '<STR_LIT>' ) <EOL> fakeclient . updateGranularity ( ) <EOL> try : <EOL> fakeclient . listRecords ( from_ = datetime ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:4> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:0> ) , <EOL> metadataPrefix = '<STR_LIT>' ) <EOL> except TestError , e : <EOL> self . assertEquals ( '<STR_LIT>' , e . kw [ '<STR_LIT>' ] ) <EOL> fakeclient = GranularityFakeClient ( granularity = '<STR_LIT>' ) <EOL> fakeclient . updateGranularity ( ) <EOL> try : <EOL> fakeclient . listRecords ( from_ = datetime ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:4> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:0> ) , <EOL> until = datetime ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:6> , <NUM_LIT> , <NUM_LIT:15> , <NUM_LIT:30> ) , <EOL> metadataPrefix = '<STR_LIT>' ) <EOL> except TestError , e : <EOL> self . assertEquals ( '<STR_LIT>' , e . kw [ '<STR_LIT>' ] ) <EOL> self . assertEquals ( '<STR_LIT>' , e . kw [ '<STR_LIT>' ] ) <EOL> def test_suite ( ) : <EOL> return TestSuite ( ( makeSuite ( ClientTestCase ) , ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( defaultTest = '<STR_LIT>' ) </s>
