def setUp(self): self.TP = TranscriptionParser() self.o = OmekaXML() from database import init_test_db self.db_session = init_test_db() self.u = User("admin", "admin@localhost", "admin", "saltypasswordhash") self.db_session.add(self.u) self.db_session.commit()
def setUp(self): from database import init_test_db self.db_session = init_test_db() self.biblio = Biblio("Lloyd's Weekly Newspaper (London, England), Sunday, December 27, 1891", date="27/12/1891", \ gale="Y3206278766", itemtype='periodical', periodical_freq="weekly", year=1891) self.biblio2 = Biblio("Lloyd's Not so Weekly Newspaper (London, England)", date="27/12/1899", \ gale="someothernumber", itemtype='periodical', periodical_freq="daily", year=1899) self.db_session.add(self.biblio) self.db_session.add(self.biblio2) self.db_session.commit()
def setUp(self): from database import init_test_db self.db_session = init_test_db() self.u = User('admin', 'admin@localhost', 'admin', 'saltypasswordhash') self.db_session.add(self.u) self.db_session.commit()
from datetime import datetime # load a db session with the data print("Creating {0} users".format(len(USERDATA))) # Users: users = [] for item in USERDATA: users.append(User(*item)) db_session.add(users[-1]) db_session.commit() # example transcription data transcriptions = [] for idx, item in enumerate(TRANSCRIPTIONS): transcriptions.append(Transcription(idx, item, datetime.now(), users[idx])) db_session.add(transcriptions[-1]) db_session.commit() if __name__ == "__main__": if sys.flags.interactive: from database import init_test_db db_session = init_test_db() load_db(db_session) print("All models have been imported, and 'db_session' is the db entrypoint.") else: print("This will load the data into an inmemory SQLite db. Please open this with an interactive shell.") print("Eg 'python -i test_load_test_data.py'") print("Quitting.")