Skip to content

Commit b51266b

Browse files
authored
feat(step-generation): introduce flex stacker fill atomic command creator (#20235)
This PR creates atomic step generation command creators for `fill` command.
1 parent 7ff8ae4 commit b51266b

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { beforeEach, describe, expect, it, vi } from 'vitest'
2+
3+
import {
4+
FLEX_STACKER_MODULE_TYPE,
5+
FLEX_STACKER_MODULE_V1,
6+
} from '@opentrons/shared-data'
7+
8+
import { flexStackerFill } from '../commandCreators/atomic/flexStackerFill'
9+
import { getInitialRobotStateStandard, makeContext } from '../fixtures'
10+
11+
import type { InvariantContext, RobotState } from '../types'
12+
13+
const moduleId = 'flexStackerId'
14+
vi.mock('../robotStateSelectors')
15+
16+
describe('flexStackerStore', () => {
17+
let invariantContext: InvariantContext
18+
let robotState: RobotState
19+
beforeEach(() => {
20+
invariantContext = makeContext()
21+
robotState = getInitialRobotStateStandard(invariantContext)
22+
invariantContext.moduleEntities[moduleId] = {
23+
id: moduleId,
24+
type: FLEX_STACKER_MODULE_TYPE,
25+
model: FLEX_STACKER_MODULE_V1,
26+
pythonName: 'mock_flex_stacker_1',
27+
}
28+
})
29+
it('creates flex stacker fill command with count', () => {
30+
const result = flexStackerFill(
31+
{
32+
moduleId,
33+
count: 10,
34+
strategy: 'manualWithPause',
35+
},
36+
invariantContext,
37+
robotState
38+
)
39+
expect(result).toEqual({
40+
commands: [
41+
{
42+
commandType: 'flexStacker/fill',
43+
key: expect.any(String),
44+
params: {
45+
moduleId,
46+
strategy: 'manualWithPause',
47+
count: 10,
48+
},
49+
},
50+
],
51+
python: 'mock_flex_stacker_1.fill(count=10)',
52+
})
53+
})
54+
it('creates flex stacker fill command with message', () => {
55+
const result = flexStackerFill(
56+
{
57+
moduleId,
58+
message: 'Filling...',
59+
strategy: 'manualWithPause',
60+
},
61+
invariantContext,
62+
robotState
63+
)
64+
expect(result).toEqual({
65+
commands: [
66+
{
67+
commandType: 'flexStacker/fill',
68+
key: expect.any(String),
69+
params: {
70+
moduleId,
71+
strategy: 'manualWithPause',
72+
message: 'Filling...',
73+
},
74+
},
75+
],
76+
python: 'mock_flex_stacker_1.fill(message="Filling...")',
77+
})
78+
})
79+
})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { formatPyStr, uuid } from '../../utils'
2+
3+
import type { FlexStackerFillCreateCommand } from '@opentrons/shared-data'
4+
import type { CommandCreator } from '../../types'
5+
6+
export const flexStackerFill: CommandCreator<
7+
FlexStackerFillCreateCommand['params']
8+
> = (args, invariantContext) => {
9+
const { moduleId, message, count, labwareToStore } = args
10+
const pythonName = invariantContext.moduleEntities[moduleId].pythonName
11+
12+
// TODO: add error creators
13+
14+
const pythonArgs = [
15+
...(count != null ? [`count=${count}`] : []),
16+
...(message != null ? [`message=${formatPyStr(message)}`] : []),
17+
]
18+
19+
return {
20+
commands: [
21+
{
22+
commandType: 'flexStacker/fill',
23+
key: uuid(),
24+
params: {
25+
moduleId,
26+
strategy: 'manualWithPause',
27+
message,
28+
count,
29+
labwareToStore,
30+
},
31+
},
32+
],
33+
python: `${pythonName}.fill(${pythonArgs.join(', ')})`,
34+
}
35+
}

0 commit comments

Comments
 (0)