<s> import shelve <EOL> import pytest <EOL> import schedule2 as schedule <EOL> @ pytest . yield_fixture <EOL> def db ( ) : <EOL> with shelve . open ( schedule . DB_NAME ) as the_db : <EOL> if schedule . CONFERENCE not in the_db : <EOL> schedule . load_db ( the_db ) <EOL> yield the_db <EOL> def test_record_attr_access ( ) : <EOL> rec = schedule . Record ( spam = <NUM_LIT> , eggs = <NUM_LIT:12> ) <EOL> assert rec . spam == <NUM_LIT> <EOL> assert rec . eggs == <NUM_LIT:12> <EOL> def test_record_repr ( ) : <EOL> rec = schedule . DbRecord ( spam = <NUM_LIT> , eggs = <NUM_LIT:12> ) <EOL> assert '<STR_LIT>' in repr ( rec ) <EOL> rec2 = schedule . DbRecord ( serial = <NUM_LIT> ) <EOL> assert repr ( rec2 ) == "<STR_LIT>" <EOL> def test_conference_record ( db ) : <EOL> assert schedule . CONFERENCE in db <EOL> def test_speaker_record ( db ) : <EOL> speaker = db [ '<STR_LIT>' ] <EOL> assert speaker . name == '<STR_LIT>' <EOL> def test_missing_db_exception ( ) : <EOL> with pytest . raises ( schedule . MissingDatabaseError ) : <EOL> schedule . DbRecord . fetch ( '<STR_LIT>' ) <EOL> def test_dbrecord ( db ) : <EOL> schedule . DbRecord . set_db ( db ) <EOL> venue = schedule . DbRecord . fetch ( '<STR_LIT>' ) <EOL> assert venue . name == '<STR_LIT>' <EOL> def test_event_record ( db ) : <EOL> event = db [ '<STR_LIT>' ] <EOL> assert repr ( event ) == "<STR_LIT>" <EOL> def test_event_venue ( db ) : <EOL> schedule . Event . set_db ( db ) <EOL> event = db [ '<STR_LIT>' ] <EOL> assert event . venue_serial == <NUM_LIT> <EOL> assert event . venue == db [ '<STR_LIT>' ] <EOL> assert event . venue . name == '<STR_LIT>' <EOL> def test_event_speakers ( db ) : <EOL> schedule . Event . set_db ( db ) <EOL> event = db [ '<STR_LIT>' ] <EOL> assert len ( event . speakers ) == <NUM_LIT:2> <EOL> anna_and_alex = [ db [ '<STR_LIT>' ] , db [ '<STR_LIT>' ] ] <EOL> assert event . speakers == anna_and_alex <EOL> def test_event_no_speakers ( db ) : <EOL> schedule . Event . set_db ( db ) <EOL> event = db [ '<STR_LIT>' ] <EOL> assert len ( event . speakers ) == <NUM_LIT:0> </s>
