Skip to content

Commit b951353

Browse files
committed
Attempt at writing unit test for 'get_session_id()' function
1 parent 822050c commit b951353

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/server/test_ispyb.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from ispyb.sqlalchemy import BLSession, Person, Proposal
2+
3+
from murfey.server.ispyb import get_session_id
4+
5+
6+
def test_get_session_id(
7+
ispyb_session,
8+
):
9+
10+
# Create some values to put into BLSession and Proposal
11+
# 'Person' is a required table
12+
person_db_entry = Person(
13+
login="murfey",
14+
)
15+
ispyb_session.add(person_db_entry)
16+
ispyb_session.commit()
17+
18+
proposal_db_entry = Proposal(
19+
personId=Person.personId,
20+
proposalCode="cm",
21+
proposalNumber="12345",
22+
)
23+
ispyb_session.add(proposal_db_entry)
24+
ispyb_session.commit()
25+
26+
bl_session_db_entry = BLSession(
27+
proposalId=proposal_db_entry.proposalId,
28+
beamLineName="murfey",
29+
visit_number=6,
30+
)
31+
ispyb_session.add(bl_session_db_entry)
32+
ispyb_session.commit()
33+
34+
# Test function
35+
result = get_session_id(
36+
microscope="murfey",
37+
proposal_code="cm",
38+
proposal_number="12345",
39+
visit_number="6",
40+
db=ispyb_session,
41+
)
42+
assert result == bl_session_db_entry.sessionId

0 commit comments

Comments
 (0)