Skip to content

Commit 7f84d4c

Browse files
committed
Added 'ISPyBTableValues' class to store default table values in ISPyB; seed ISPyB database with ExperimentType information as well
1 parent 88b3bee commit 7f84d4c

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

tests/conftest.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import ispyb
1010
import pytest
11-
from ispyb.sqlalchemy import BLSession, Person, Proposal, url
11+
from ispyb.sqlalchemy import BLSession, ExperimentType, Person, Proposal, url
1212
from sqlalchemy import Engine, RootTransaction, and_, create_engine, event, select
1313
from sqlalchemy.ext.declarative import DeclarativeMeta
1414
from sqlalchemy.orm import Session as SQLAlchemySession
@@ -87,8 +87,8 @@ def mock_security_configuration(
8787

8888
class 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+
110123
SQLAlchemyTable = 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

Comments
 (0)