88
99import ispyb
1010import pytest
11- from ispyb .sqlalchemy import BLSession , Person , Proposal , url
11+ from ispyb .sqlalchemy import BLSession , ExperimentType , Person , Proposal , url
1212from sqlalchemy import Engine , RootTransaction , and_ , create_engine , event , select
1313from sqlalchemy .ext .declarative import DeclarativeMeta
1414from sqlalchemy .orm import Session as SQLAlchemySession
@@ -87,8 +87,8 @@ def mock_security_configuration(
8787
8888class ExampleVisit :
8989 """
90- This is a class to store information that will common to all database entries for
91- a particular Murfey session, to enable ease of replication when creating database
90+ This class stores information that will be common to all database entries for a
91+ particular Murfey session, to enable ease of replication when creating database
9292 fixtures.
9393 """
9494
@@ -107,6 +107,19 @@ class ExampleVisit:
107107 login = "murfey123"
108108
109109
110+ class ISPyBTableValues :
111+ """
112+ Visit-independent default values for ISPyB tables
113+ """
114+
115+ # ExperimentType (ISPyB)
116+ experiment_types = {
117+ "Tomography" : 36 ,
118+ "Single Particle" : 37 ,
119+ "Atlas" : 44 ,
120+ }
121+
122+
110123SQLAlchemyTable = TypeVar ("SQLAlchemyTable" , bound = DeclarativeMeta )
111124
112125
@@ -215,6 +228,19 @@ def seed_ispyb_db(ispyb_db_session_factory):
215228 "visit_number" : ExampleVisit .visit_number ,
216229 },
217230 )
231+ _ = [
232+ get_or_create_db_entry (
233+ session = ispyb_db_session ,
234+ table = ExperimentType ,
235+ lookup_kwargs = {
236+ "experimentTypeId" : id ,
237+ "name" : name ,
238+ "proposalType" : "em" ,
239+ "active" : 1 ,
240+ },
241+ )
242+ for name , id in ISPyBTableValues .experiment_types .items ()
243+ ]
218244 ispyb_db_session .close ()
219245
220246
0 commit comments