Skip to content

Commit 8393b61

Browse files
author
David Erb
committed
fixes test by inserting soakdb3 head record
1 parent e6b95e6 commit 8393b61

File tree

1 file changed

+53
-10
lines changed

1 file changed

+53
-10
lines changed

tests/test_export.py

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
import logging
33
from pathlib import Path
44

5-
# Base class for the tester.
65
# API constants.
76
from dls_servbase_lib.datafaces.context import Context as DlsServbaseDatafaceContext
87
from dls_utilpack.visit import get_xchem_subdirectory
98

9+
# Soakdb3 database.
10+
from soakdb3_api.databases.constants import Tablenames
11+
12+
# Client for direct access to the soakdb3 database for seeding it.
13+
from soakdb3_api.datafaces.context import Context as Soakdb3DatafaceClientContext
14+
from soakdb3_api.datafaces.datafaces import (
15+
datafaces_get_default as soakdb3_datafaces_get_default,
16+
)
17+
1018
# The service process startup/teardown context.
1119
from soakdb3_lib.datafaces.context import Context as Soakdb3DatafaceServerContext
1220

@@ -67,6 +75,11 @@ async def _main_coroutine(self, constants, output_directory):
6775
soakdb3_dataface_specification
6876
)
6977

78+
# Make the soakdb3 CLIENT context.
79+
soakdb3_client_context = Soakdb3DatafaceClientContext(
80+
soakdb3_dataface_specification
81+
)
82+
7083
# Reference the dict entry for the xchembku dataface.
7184
xchembku_dataface_specification = multiconf_dict[
7285
"xchembku_dataface_specification"
@@ -93,20 +106,26 @@ async def _main_coroutine(self, constants, output_directory):
93106

94107
# Start the soakdb3 server context which includes the direct or network-addressable service.
95108
async with soakdb3_server_context:
96-
# Start the client context for the direct access to the xchembku.
97-
async with xchembku_client_context:
98-
# Start the dataface the gui uses for cookies.
99-
async with servbase_dataface_context:
100-
# Start the gui client context.
101-
async with gui_client_context:
102-
# And the gui server context which starts the coro.
103-
async with gui_server_context:
104-
await self.__run_part1(constants, output_directory)
109+
# Client for direct access to the soakdb3 database for seeding it.
110+
async with soakdb3_client_context:
111+
# Start the client context for the direct access to the xchembku.
112+
async with xchembku_client_context:
113+
# Start the dataface the gui uses for cookies.
114+
async with servbase_dataface_context:
115+
# Start the gui client context.
116+
async with gui_client_context:
117+
# And the gui server context which starts the coro.
118+
async with gui_server_context:
119+
await self.__run_part1(constants, output_directory)
105120

106121
# ----------------------------------------------------------------------------------------
107122

108123
async def __run_part1(self, constants, output_directory):
109124
""" """
125+
126+
# Reference the soakdb3 dataface object which the context has set up as the default.
127+
soakdb3_dataface = soakdb3_datafaces_get_default()
128+
110129
# Reference the xchembku object which the context has set up as the default.
111130
self.__xchembku = xchembku_datafaces_get_default()
112131

@@ -120,12 +139,36 @@ async def __run_part1(self, constants, output_directory):
120139
/ get_xchem_subdirectory(self.visit)
121140
)
122141

142+
# Soakdb3 expects visitid to be a visit directory.
143+
# This is because of how the soadkb3 VBA in the Excel works.
144+
visitid = str(self.__visit_directory / "processing")
145+
123146
self.__crystal_targets_directory = (
124147
self.__visit_directory / "processing/lab36/crystal-targets"
125148
)
126149

127150
self.__crystal_targets_directory.mkdir(parents=True)
128151

152+
# ----------------------------------------------------------------
153+
# Seed the necessary fields in the head table.
154+
155+
protein = "P1"
156+
drop_volume = 3.1
157+
158+
head_record = {
159+
"Protein": protein,
160+
"DropVolume": drop_volume,
161+
}
162+
163+
# Insert these fields as the (single) row in the soakdb3 database's head table.
164+
await soakdb3_dataface.insert( # type: ignore
165+
visitid,
166+
Tablenames.HEAD,
167+
[head_record],
168+
)
169+
170+
# ----------------------------------------------------------------
171+
129172
await self.__export_initial()
130173

131174
crystal_wells = []

0 commit comments

Comments
 (0)