<s> from base import * <EOL> from bibserver . importer import Importer <EOL> import bibserver . dao <EOL> import os <EOL> class TestImporter : <EOL> @ classmethod <EOL> def setup_class ( cls ) : <EOL> pass <EOL> @ classmethod <EOL> def teardown_class ( cls ) : <EOL> conn , db = dao . get_conn ( ) <EOL> conn . delete_index ( TESTDB ) <EOL> def test_upload ( self ) : <EOL> owner = dao . Account ( id = '<STR_LIT>' ) <EOL> owner . save ( ) <EOL> i = Importer ( owner = owner ) <EOL> data = open ( '<STR_LIT>' ) <EOL> collection_in = { <EOL> '<STR_LIT:label>' : u'<STR_LIT>' <EOL> } <EOL> coll , records = i . upload ( data , collection_in ) <EOL> assert coll . id <EOL> assert owner . collections [ <NUM_LIT:0> ] . id == coll . id , owner . collections <EOL> assert len ( records ) == <NUM_LIT:1> , records <EOL> recid = records [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> out = bibserver . dao . Record . get ( recid ) <EOL> assert out [ "<STR_LIT>" ] == '<STR_LIT>' , out <EOL> assert out [ '<STR_LIT>' ] == coll [ '<STR_LIT>' ] <EOL> data = open ( '<STR_LIT>' ) <EOL> newcoll , records = i . upload ( data , collection_in ) <EOL> assert len ( owner . collections ) == <NUM_LIT:1> <EOL> assert newcoll . id == coll . id <EOL> assert len ( records ) == <NUM_LIT:1> <EOL> assert records [ <NUM_LIT:0> ] [ '<STR_LIT>' ] == coll [ '<STR_LIT>' ] <EOL> recs_for_collection = dao . Record . query ( '<STR_LIT>' + coll [ '<STR_LIT>' ] + '<STR_LIT:">' ) <EOL> assert recs_for_collection [ '<STR_LIT>' ] [ '<STR_LIT>' ] == <NUM_LIT:1> , recs_for_collection </s>
