@opentrons/shared-data 0.0.1-alpha.20 → 0.0.1-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/package.json +1 -1
  2. package/js/__tests__/__snapshots__/pipettes.test.ts.snap +0 -5969
  3. package/js/__tests__/deckSchemas.test.ts +0 -87
  4. package/js/__tests__/errors.test.js +0 -21
  5. package/js/__tests__/getAreSlotsAdjacent.test.ts +0 -128
  6. package/js/__tests__/getWellNamePerMultiTip.test.ts +0 -162
  7. package/js/__tests__/labwareDefQuirks.test.ts +0 -37
  8. package/js/__tests__/labwareDefSchemaV1.test.ts +0 -82
  9. package/js/__tests__/labwareDefSchemaV2.test.ts +0 -298
  10. package/js/__tests__/moduleAccessors.test.ts +0 -50
  11. package/js/__tests__/moduleSpecsSchema.test.ts +0 -77
  12. package/js/__tests__/pipetteSchemaV2.test.ts +0 -107
  13. package/js/__tests__/pipetteSpecSchemas.test.ts +0 -48
  14. package/js/__tests__/pipettes.test.ts +0 -58
  15. package/js/__tests__/protocolSchemaV4.test.ts +0 -137
  16. package/js/__tests__/protocolSchemaV5.test.ts +0 -137
  17. package/js/__tests__/protocolSchemaV6.test.ts +0 -132
  18. package/js/__tests__/protocolSchemaV7.test.ts +0 -64
  19. package/js/__tests__/protocolValidation.test.ts +0 -83
  20. package/js/__tests__/sortWells.test.ts +0 -40
  21. package/js/__tests__/splitWellsOnColumn.test.ts +0 -21
  22. package/js/__tests__/validateErrors.test.js +0 -34
  23. package/js/constants.ts +0 -338
  24. package/js/cypressUtils.ts +0 -35
  25. package/js/errors.ts +0 -33
  26. package/js/fixtures.ts +0 -161
  27. package/js/getLabware.ts +0 -154
  28. package/js/gripper.ts +0 -29
  29. package/js/helpers/__tests__/getAdapterName.test.ts +0 -31
  30. package/js/helpers/__tests__/getDeckDefFromLoadedLabware.test.ts +0 -12
  31. package/js/helpers/__tests__/getVectorDifference.test.ts +0 -25
  32. package/js/helpers/__tests__/getVectorSum.test.ts +0 -21
  33. package/js/helpers/__tests__/labwareInference.test.ts +0 -84
  34. package/js/helpers/__tests__/orderWells.test.ts +0 -87
  35. package/js/helpers/__tests__/parseProtocolData.test.ts +0 -165
  36. package/js/helpers/__tests__/volume.test.ts +0 -108
  37. package/js/helpers/__tests__/wellSets.test.ts +0 -352
  38. package/js/helpers/get96Channel384WellPlateWells.ts +0 -44
  39. package/js/helpers/getAddressableAreasInProtocol.ts +0 -59
  40. package/js/helpers/getLoadedLabwareDefinitionsByUri.ts +0 -30
  41. package/js/helpers/getModuleVizDims.ts +0 -118
  42. package/js/helpers/getOccludedSlotCountForModule.ts +0 -13
  43. package/js/helpers/getVectorDifference.ts +0 -12
  44. package/js/helpers/getVectorSum.ts +0 -12
  45. package/js/helpers/getWellNamePerMultiTip.ts +0 -86
  46. package/js/helpers/getWellTotalVolume.ts +0 -16
  47. package/js/helpers/index.ts +0 -347
  48. package/js/helpers/labwareInference.ts +0 -92
  49. package/js/helpers/orderWells.ts +0 -69
  50. package/js/helpers/parseProtocolData.ts +0 -141
  51. package/js/helpers/volume.ts +0 -35
  52. package/js/helpers/wellIsRect.ts +0 -6
  53. package/js/helpers/wellSets.ts +0 -155
  54. package/js/index.ts +0 -14
  55. package/js/labwareTools/__tests__/__snapshots__/createIrregularLabware.test.ts.snap +0 -3
  56. package/js/labwareTools/__tests__/__snapshots__/createLabware.test.ts.snap +0 -3
  57. package/js/labwareTools/__tests__/createDefaultDisplayName.test.ts +0 -111
  58. package/js/labwareTools/__tests__/createIrregularLabware.test.ts +0 -226
  59. package/js/labwareTools/__tests__/createLabware.test.ts +0 -147
  60. package/js/labwareTools/index.ts +0 -452
  61. package/js/modules.ts +0 -97
  62. package/js/pipettes.ts +0 -89
  63. package/js/protocols.ts +0 -290
  64. package/js/schema.ts +0 -80
  65. package/js/scripts/generateDeckLayersFromSVG.js +0 -46
  66. package/js/titleCase.ts +0 -30
  67. package/js/types.ts +0 -600
  68. package/python/.coveragerc +0 -4
  69. package/python/.flake8 +0 -32
  70. package/python/Config.in +0 -10
  71. package/python/Makefile +0 -134
  72. package/python/Pipfile +0 -28
  73. package/python/Pipfile.lock +0 -645
  74. package/python/buildroot.mk +0 -30
  75. package/python/mypy.ini +0 -41
  76. package/python/opentrons_shared_data/__init__.py +0 -17
  77. package/python/opentrons_shared_data/_version.py +0 -20
  78. package/python/opentrons_shared_data/command/__init__.py +0 -52
  79. package/python/opentrons_shared_data/deck/__init__.py +0 -96
  80. package/python/opentrons_shared_data/deck/dev_types.py +0 -180
  81. package/python/opentrons_shared_data/errors/__init__.py +0 -30
  82. package/python/opentrons_shared_data/errors/categories.py +0 -60
  83. package/python/opentrons_shared_data/errors/codes.py +0 -108
  84. package/python/opentrons_shared_data/errors/exceptions.py +0 -915
  85. package/python/opentrons_shared_data/gripper/__init__.py +0 -63
  86. package/python/opentrons_shared_data/gripper/constants.py +0 -6
  87. package/python/opentrons_shared_data/gripper/gripper_definition.py +0 -101
  88. package/python/opentrons_shared_data/labware/__init__.py +0 -22
  89. package/python/opentrons_shared_data/labware/constants.py +0 -7
  90. package/python/opentrons_shared_data/labware/dev_types.py +0 -140
  91. package/python/opentrons_shared_data/labware/labware_definition.py +0 -328
  92. package/python/opentrons_shared_data/load.py +0 -57
  93. package/python/opentrons_shared_data/module/__init__.py +0 -74
  94. package/python/opentrons_shared_data/module/dev_types.py +0 -141
  95. package/python/opentrons_shared_data/pipette/__init__.py +0 -107
  96. package/python/opentrons_shared_data/pipette/dev_types.py +0 -177
  97. package/python/opentrons_shared_data/pipette/file_operation_helpers.py +0 -37
  98. package/python/opentrons_shared_data/pipette/load_data.py +0 -261
  99. package/python/opentrons_shared_data/pipette/model_constants.py +0 -123
  100. package/python/opentrons_shared_data/pipette/mutable_configurations.py +0 -431
  101. package/python/opentrons_shared_data/pipette/pipette_definition.py +0 -503
  102. package/python/opentrons_shared_data/pipette/pipette_load_name_conversions.py +0 -240
  103. package/python/opentrons_shared_data/pipette/scripts/__init__.py +0 -0
  104. package/python/opentrons_shared_data/pipette/scripts/build_json_script.py +0 -469
  105. package/python/opentrons_shared_data/pipette/scripts/update_configuration_files.py +0 -450
  106. package/python/opentrons_shared_data/pipette/types.py +0 -193
  107. package/python/opentrons_shared_data/protocol/__init__.py +0 -13
  108. package/python/opentrons_shared_data/protocol/constants.py +0 -98
  109. package/python/opentrons_shared_data/protocol/dev_types.py +0 -436
  110. package/python/opentrons_shared_data/protocol/models/__init__.py +0 -48
  111. package/python/opentrons_shared_data/protocol/models/protocol_schema_v6.py +0 -145
  112. package/python/opentrons_shared_data/protocol/models/protocol_schema_v7.py +0 -95
  113. package/python/opentrons_shared_data/protocol/models/protocol_schema_v8.py +0 -110
  114. package/python/opentrons_shared_data/protocol/models/shared_models.py +0 -111
  115. package/python/opentrons_shared_data/py.typed +0 -0
  116. package/python/opentrons_shared_data/robot/__init__.py +0 -33
  117. package/python/opentrons_shared_data/robot/dev_types.py +0 -37
  118. package/python/pytest.ini +0 -2
  119. package/python/setup.cfg +0 -5
  120. package/python/setup.py +0 -179
  121. package/python/tests/__init__.py +0 -1
  122. package/python/tests/conftest.py +0 -0
  123. package/python/tests/deck/__init__.py +0 -0
  124. package/python/tests/deck/test_list_names.py +0 -12
  125. package/python/tests/deck/test_position.py +0 -113
  126. package/python/tests/deck/test_typechecks.py +0 -28
  127. package/python/tests/errors/__init__.py +0 -1
  128. package/python/tests/errors/test_error_completeness.py +0 -19
  129. package/python/tests/errors/test_exceptions.py +0 -74
  130. package/python/tests/gripper/__init__.py +0 -0
  131. package/python/tests/gripper/test_definition.py +0 -30
  132. package/python/tests/gripper/test_load.py +0 -16
  133. package/python/tests/labware/__init__.py +0 -13
  134. package/python/tests/labware/test_typechecks.py +0 -21
  135. package/python/tests/module/__init__.py +0 -20
  136. package/python/tests/module/test_load.py +0 -49
  137. package/python/tests/module/test_typechecks.py +0 -34
  138. package/python/tests/pipette/__init__.py +0 -0
  139. package/python/tests/pipette/test_load_data.py +0 -103
  140. package/python/tests/pipette/test_mutable_configurations.py +0 -266
  141. package/python/tests/pipette/test_pipette_definition.py +0 -183
  142. package/python/tests/pipette/test_pipette_load_name_conversions.py +0 -222
  143. package/python/tests/pipette/test_typechecks.py +0 -50
  144. package/python/tests/pipette/test_validate_schema.py +0 -37
  145. package/python/tests/protocol/__init__.py +0 -15
  146. package/python/tests/protocol/test_protocol_schema_v6.py +0 -107
  147. package/python/tests/protocol/test_protocol_schema_v7.py +0 -34
  148. package/python/tests/protocol/test_protocol_schema_v8.py +0 -20
  149. package/python/tests/protocol/test_typechecks.py +0 -36
  150. package/python/tests/robot/__init__.py +0 -0
  151. package/python/tests/robot/test_typechecks.py +0 -20
@@ -1,137 +0,0 @@
1
- /** Ensure that protocol schema v4 definition itself functions as intended,
2
- * and that all v4 protocol fixtures will validate */
3
- import Ajv from 'ajv'
4
- import path from 'path'
5
- import glob from 'glob'
6
- import omit from 'lodash/omit'
7
-
8
- import protocolSchema from '../../protocol/schemas/4.json'
9
- import labwareV2Schema from '../../labware/schemas/2.json'
10
- import simpleV4Fixture from '../../protocol/fixtures/4/simpleV4.json'
11
-
12
- const fixturesGlobPath = path.join(
13
- __dirname,
14
- '../../protocol/fixtures/4/**/*.json'
15
- )
16
-
17
- const protocolFixtures = glob.sync(fixturesGlobPath)
18
- const ajv = new Ajv({ allErrors: true, jsonPointers: true })
19
-
20
- // v4 protocol schema contains reference to v2 labware schema, so give AJV access to it
21
- ajv.addSchema(labwareV2Schema)
22
-
23
- const validateProtocol = ajv.compile(protocolSchema)
24
-
25
- describe('validate v4 protocol fixtures under JSON schema', () => {
26
- protocolFixtures.forEach(protocolPath => {
27
- it(path.basename(protocolPath), () => {
28
- const protocol = require(protocolPath)
29
-
30
- const valid = validateProtocol(protocol)
31
- const validationErrors = validateProtocol.errors
32
-
33
- if (validationErrors) {
34
- console.log(JSON.stringify(validationErrors, null, 4))
35
- }
36
-
37
- expect(validationErrors).toBe(null)
38
- expect(valid).toBe(true)
39
- })
40
- })
41
- })
42
-
43
- describe('ensure bad protocol data fails validation', () => {
44
- it('$otSharedSchema is required to be "#/protocol/schemas/4"', () => {
45
- expect(validateProtocol(omit(simpleV4Fixture, '$otSharedSchema'))).toBe(
46
- false
47
- )
48
- expect(
49
- validateProtocol({
50
- ...simpleV4Fixture,
51
- $otSharedSchema: '#/protocol/schemas/5',
52
- })
53
- ).toBe(false)
54
- })
55
-
56
- it('schemaVersion is required to be 4', () => {
57
- expect(validateProtocol(omit(simpleV4Fixture, 'schemaVersion'))).toBe(false)
58
- expect(validateProtocol({ ...simpleV4Fixture, schemaVersion: 3 })).toBe(
59
- false
60
- )
61
- })
62
-
63
- it('reject bad values in "pipettes" objects', () => {
64
- const badPipettes = {
65
- missingKeys: {},
66
- missingName: { mount: 'left' },
67
- missingMount: { name: 'pipetteName' },
68
- badMount: { mount: 'blah', name: 'pipetteName' },
69
- hasAdditionalProperties: {
70
- mount: 'left',
71
- name: 'pipetteName',
72
- blah: 'blah',
73
- },
74
- }
75
-
76
- Object.entries(badPipettes).forEach(([pipetteId, pipette]) => {
77
- expect(
78
- validateProtocol({
79
- ...simpleV4Fixture,
80
- pipettes: {
81
- ...simpleV4Fixture.pipettes,
82
- [pipetteId]: pipette,
83
- },
84
- })
85
- ).toBe(false)
86
- })
87
- })
88
-
89
- it('reject bad values in "labware" objects', () => {
90
- const badLabware = {
91
- noSlot: { definitionId: 'defId' },
92
- noDefId: { slot: '1' },
93
- hasAdditionalProperties: {
94
- slot: '1',
95
- definitionId: 'defId',
96
- blah: 'blah',
97
- },
98
- }
99
-
100
- Object.entries(badLabware).forEach(([labwareId, labware]) => {
101
- expect(
102
- validateProtocol({
103
- ...simpleV4Fixture,
104
- labware: {
105
- ...simpleV4Fixture.labware,
106
- [labwareId]: labware,
107
- },
108
- })
109
- ).toBe(false)
110
- })
111
- })
112
-
113
- it('reject bad values in "modules" objects', () => {
114
- const badModules = {
115
- badModuleType: { slot: '1', moduleType: 'fake' },
116
- noSlot: { moduleType: 'thermocycler' },
117
- noModuleType: { slot: '1' },
118
- hasAdditionalProperties: {
119
- slot: '1',
120
- moduleType: 'thermocycler',
121
- blah: 'blah',
122
- },
123
- }
124
-
125
- Object.entries(badModules).forEach(([moduleId, module]) => {
126
- expect(
127
- validateProtocol({
128
- ...simpleV4Fixture,
129
- modules: {
130
- ...simpleV4Fixture.modules,
131
- [moduleId]: module,
132
- },
133
- })
134
- ).toBe(false)
135
- })
136
- })
137
- })
@@ -1,137 +0,0 @@
1
- /** Ensure that protocol schema v5 definition itself functions as intended,
2
- * and that all v5 protocol fixtures will validate */
3
- import Ajv from 'ajv'
4
- import path from 'path'
5
- import glob from 'glob'
6
- import omit from 'lodash/omit'
7
-
8
- import protocolSchema from '../../protocol/schemas/5.json'
9
- import labwareV2Schema from '../../labware/schemas/2.json'
10
- import simpleV5Fixture from '../../protocol/fixtures/5/simpleV5.json'
11
-
12
- const fixturesGlobPath = path.join(
13
- __dirname,
14
- '../../protocol/fixtures/5/**/*.json'
15
- )
16
-
17
- const protocolFixtures = glob.sync(fixturesGlobPath)
18
- const ajv = new Ajv({ allErrors: true, jsonPointers: true })
19
-
20
- // v5 protocol schema contains reference to v2 labware schema, so give AJV access to it
21
- ajv.addSchema(labwareV2Schema)
22
-
23
- const validateProtocol = ajv.compile(protocolSchema)
24
-
25
- describe('validate v5 protocol fixtures under JSON schema', () => {
26
- protocolFixtures.forEach(protocolPath => {
27
- it(path.basename(protocolPath), () => {
28
- const protocol = require(protocolPath)
29
-
30
- const valid = validateProtocol(protocol)
31
- const validationErrors = validateProtocol.errors
32
-
33
- if (validationErrors) {
34
- console.log(JSON.stringify(validationErrors, null, 4))
35
- }
36
-
37
- expect(validationErrors).toBe(null)
38
- expect(valid).toBe(true)
39
- })
40
- })
41
- })
42
-
43
- describe('ensure bad protocol data fails validation', () => {
44
- it('$otSharedSchema is required to be "#/protocol/schemas/5"', () => {
45
- expect(validateProtocol(omit(simpleV5Fixture, '$otSharedSchema'))).toBe(
46
- false
47
- )
48
- expect(
49
- validateProtocol({
50
- ...simpleV5Fixture,
51
- $otSharedSchema: '#/protocol/schemas/6',
52
- })
53
- ).toBe(false)
54
- })
55
-
56
- it('schemaVersion is required to be 5', () => {
57
- expect(validateProtocol(omit(simpleV5Fixture, 'schemaVersion'))).toBe(false)
58
- expect(validateProtocol({ ...simpleV5Fixture, schemaVersion: 3 })).toBe(
59
- false
60
- )
61
- })
62
-
63
- it('reject bad values in "pipettes" objects', () => {
64
- const badPipettes = {
65
- missingKeys: {},
66
- missingName: { mount: 'left' },
67
- missingMount: { name: 'pipetteName' },
68
- badMount: { mount: 'blah', name: 'pipetteName' },
69
- hasAdditionalProperties: {
70
- mount: 'left',
71
- name: 'pipetteName',
72
- blah: 'blah',
73
- },
74
- }
75
-
76
- Object.entries(badPipettes).forEach(([pipetteId, pipette]) => {
77
- expect(
78
- validateProtocol({
79
- ...simpleV5Fixture,
80
- pipettes: {
81
- ...simpleV5Fixture.pipettes,
82
- [pipetteId]: pipette,
83
- },
84
- })
85
- ).toBe(false)
86
- })
87
- })
88
-
89
- it('reject bad values in "labware" objects', () => {
90
- const badLabware = {
91
- noSlot: { definitionId: 'defId' },
92
- noDefId: { slot: '1' },
93
- hasAdditionalProperties: {
94
- slot: '1',
95
- definitionId: 'defId',
96
- blah: 'blah',
97
- },
98
- }
99
-
100
- Object.entries(badLabware).forEach(([labwareId, labware]) => {
101
- expect(
102
- validateProtocol({
103
- ...simpleV5Fixture,
104
- labware: {
105
- ...simpleV5Fixture.labware,
106
- [labwareId]: labware,
107
- },
108
- })
109
- ).toBe(false)
110
- })
111
- })
112
-
113
- it('reject bad values in "modules" objects', () => {
114
- const badModules = {
115
- badModuleType: { slot: '1', moduleType: 'fake' },
116
- noSlot: { moduleType: 'thermocycler' },
117
- noModuleType: { slot: '1' },
118
- hasAdditionalProperties: {
119
- slot: '1',
120
- moduleType: 'thermocycler',
121
- blah: 'blah',
122
- },
123
- }
124
-
125
- Object.entries(badModules).forEach(([moduleId, module]) => {
126
- expect(
127
- validateProtocol({
128
- ...simpleV5Fixture,
129
- modules: {
130
- ...simpleV5Fixture.modules,
131
- [moduleId]: module,
132
- },
133
- })
134
- ).toBe(false)
135
- })
136
- })
137
- })
@@ -1,132 +0,0 @@
1
- /** Ensure that protocol schema v6 definition itself functions as intended,
2
- * and that all v6 protocol fixtures will validate */
3
- import Ajv from 'ajv'
4
- import path from 'path'
5
- import glob from 'glob'
6
- import omit from 'lodash/omit'
7
-
8
- import protocolSchema from '../../protocol/schemas/6.json'
9
- import labwareV2Schema from '../../labware/schemas/2.json'
10
- import simpleV6Fixture from '../../protocol/fixtures/6/simpleV6.json'
11
-
12
- const fixturesGlobPath = path.join(
13
- __dirname,
14
- '../../protocol/fixtures/6/**/*.json'
15
- )
16
-
17
- const protocolFixtures = glob.sync(fixturesGlobPath)
18
- const ajv = new Ajv({ allErrors: true, jsonPointers: true })
19
-
20
- // v6 protocol schema contains reference to v2 labware schema, so give AJV access to it
21
- ajv.addSchema(labwareV2Schema)
22
-
23
- const validateProtocol = ajv.compile(protocolSchema)
24
-
25
- describe('validate v6 protocol fixtures under JSON schema', () => {
26
- protocolFixtures.forEach(protocolPath => {
27
- it(path.basename(protocolPath), () => {
28
- const protocol = require(protocolPath)
29
-
30
- const valid = validateProtocol(protocol)
31
- const validationErrors = validateProtocol.errors
32
-
33
- if (validationErrors) {
34
- console.log(JSON.stringify(validationErrors, null, 4))
35
- }
36
-
37
- expect(validationErrors).toBe(null)
38
- expect(valid).toBe(true)
39
- })
40
- })
41
- })
42
-
43
- describe('ensure bad protocol data fails validation', () => {
44
- it('$otSharedSchema is required to be "#/protocol/schemas/6"', () => {
45
- expect(validateProtocol(omit(simpleV6Fixture, '$otSharedSchema'))).toBe(
46
- false
47
- )
48
- expect(
49
- validateProtocol({
50
- ...simpleV6Fixture,
51
- $otSharedSchema: '#/protocol/schemas/3',
52
- })
53
- ).toBe(false)
54
- })
55
-
56
- it('schemaVersion is required to be 6', () => {
57
- expect(validateProtocol(omit(simpleV6Fixture, 'schemaVersion'))).toBe(false)
58
- expect(validateProtocol({ ...simpleV6Fixture, schemaVersion: 3 })).toBe(
59
- false
60
- )
61
- })
62
-
63
- it('reject bad values in "pipettes" objects', () => {
64
- const badPipettes = {
65
- missingKeys: {},
66
- missingName: { mount: 'left' },
67
- hasAdditionalProperties: {
68
- mount: 'left',
69
- name: 'pipetteName',
70
- blah: 'blah',
71
- },
72
- }
73
-
74
- Object.entries(badPipettes).forEach(([pipetteId, pipette]) => {
75
- expect(
76
- validateProtocol({
77
- ...simpleV6Fixture,
78
- pipettes: {
79
- ...simpleV6Fixture.pipettes,
80
- [pipetteId]: pipette,
81
- },
82
- })
83
- ).toBe(false)
84
- })
85
- })
86
-
87
- it('reject bad values in "labware" objects', () => {
88
- const badLabware = {
89
- noDefId: { displayName: 'myLabware' },
90
- hasAdditionalProperties: {
91
- slot: '1',
92
- definitionId: 'defId',
93
- blah: 'blah',
94
- },
95
- }
96
-
97
- Object.entries(badLabware).forEach(([labwareId, labware]) => {
98
- expect(
99
- validateProtocol({
100
- ...simpleV6Fixture,
101
- labware: {
102
- ...simpleV6Fixture.labware,
103
- [labwareId]: labware,
104
- },
105
- })
106
- ).toBe(false)
107
- })
108
- })
109
-
110
- it('reject bad values in "modules" objects', () => {
111
- const badModules = {
112
- noModel: { moduleType: 'thermocycler' },
113
- hasAdditionalProperties: {
114
- model: 'thermocycler',
115
- slot: '1',
116
- blah: 'blah',
117
- },
118
- }
119
-
120
- Object.entries(badModules).forEach(([moduleId, module]) => {
121
- expect(
122
- validateProtocol({
123
- ...simpleV6Fixture,
124
- modules: {
125
- ...simpleV6Fixture.modules,
126
- [moduleId]: module,
127
- },
128
- })
129
- ).toBe(false)
130
- })
131
- })
132
- })
@@ -1,64 +0,0 @@
1
- /** Ensure that protocol schema v7 definition itself functions as intended,
2
- * and that all v7 protocol fixtures will validate */
3
- import Ajv from 'ajv'
4
- import path from 'path'
5
- import glob from 'glob'
6
- import omit from 'lodash/omit'
7
-
8
- import protocolSchema from '../../protocol/schemas/7.json'
9
- import labwareV2Schema from '../../labware/schemas/2.json'
10
- import commandV7Schema from '../../command/schemas/7.json'
11
- import simpleV7Fixture from '../../protocol/fixtures/7/simpleV7.json'
12
-
13
- const fixturesGlobPath = path.join(
14
- __dirname,
15
- '../../protocol/fixtures/7/**/*.json'
16
- )
17
-
18
- const protocolFixtures = glob.sync(fixturesGlobPath)
19
- const ajv = new Ajv({ allErrors: true, jsonPointers: true })
20
-
21
- // v7 protocol schema contains reference to v2 labware schema, and v7 command schema, so give AJV access to it
22
- ajv.addSchema(labwareV2Schema)
23
- ajv.addSchema(commandV7Schema)
24
-
25
- const validateProtocol = ajv.compile(protocolSchema)
26
-
27
- describe('validate v7 protocol fixtures under JSON schema', () => {
28
- protocolFixtures.forEach(protocolPath => {
29
- it(path.basename(protocolPath), () => {
30
- const protocol = require(protocolPath)
31
-
32
- const valid = validateProtocol(protocol)
33
- const validationErrors = validateProtocol.errors
34
-
35
- if (validationErrors) {
36
- console.log(JSON.stringify(validationErrors, null, 4))
37
- }
38
-
39
- expect(validationErrors).toBe(null)
40
- expect(valid).toBe(true)
41
- })
42
- })
43
- })
44
-
45
- describe('ensure bad protocol data fails validation', () => {
46
- it('$otSharedSchema is required to be "#/protocol/schemas/7"', () => {
47
- expect(validateProtocol(omit(simpleV7Fixture, '$otSharedSchema'))).toBe(
48
- false
49
- )
50
- expect(
51
- validateProtocol({
52
- ...simpleV7Fixture,
53
- $otSharedSchema: '#/protocol/schemas/3',
54
- })
55
- ).toBe(false)
56
- })
57
-
58
- it('schemaVersion is required to be 7', () => {
59
- expect(validateProtocol(omit(simpleV7Fixture, 'schemaVersion'))).toBe(false)
60
- expect(validateProtocol({ ...simpleV7Fixture, schemaVersion: 3 })).toBe(
61
- false
62
- )
63
- })
64
- })
@@ -1,83 +0,0 @@
1
- /** Ensure that we can parse all our fixture json protocols, which also
2
- * ensures that our protocol schemas are correct */
3
- import path from 'path'
4
- import glob from 'glob'
5
- import { validate } from '../protocols'
6
- import { omit } from 'lodash'
7
-
8
- const relRoot = path.join(__dirname, '../../protocol/fixtures/')
9
-
10
- const protocolFixtures4 = glob.sync(
11
- path.join(__dirname, '../../protocol/fixtures/4/*.json')
12
- )
13
- const protocolFixtures5 = glob.sync(
14
- path.join(__dirname, '../../protocol/fixtures/5/*.json')
15
- )
16
- const protocolFixtures6 = glob.sync(
17
- path.join(__dirname, '../../protocol/fixtures/6/*.json')
18
- )
19
- const protocolFixtures7 = glob.sync(
20
- path.join(__dirname, '../../protocol/fixtures/7/*.json')
21
- )
22
- const protocolFixtures8 = glob.sync(
23
- path.join(__dirname, '../../protocol/fixtures/8/*.json')
24
- )
25
-
26
- describe('check that all fixtures can validate', () => {
27
- const protocolPaths = [
28
- ...protocolFixtures4,
29
- ...protocolFixtures5,
30
- ...protocolFixtures6,
31
- ...protocolFixtures7,
32
- ...protocolFixtures8,
33
- ]
34
- protocolPaths.forEach(protocolPath =>
35
- it(`${path.relative(relRoot, protocolPath)}`, () => {
36
- const protocol = require(protocolPath)
37
- return validate(protocol)
38
- })
39
- )
40
- })
41
-
42
- describe('test that mutating v8 fixtures causes failure', () => {
43
- const base = require('../../protocol/fixtures/8/simpleV8.json')
44
- it('should fail validation with no schema spec', () => {
45
- const mangled = omit(base, '$otSharedSchema')
46
- expect.assertions(1)
47
- return expect(validate(mangled)).rejects.toMatchObject([
48
- { keyword: 'Invalid protocol schema requested' },
49
- ])
50
- })
51
- it('should fail validation with a schema spec from the future', () => {
52
- const mangled = { ...base, $otSharedSchema: 'opentronsProtocolSchemaV9' }
53
- expect.assertions(1)
54
- return expect(validate(mangled)).rejects.toMatchObject([
55
- { keyword: 'Invalid protocol schema requested' },
56
- ])
57
- })
58
- it('should fail validation with a mangled schema spec', () => {
59
- const mangled = { ...base, $otSharedSchema: 'asdhasda' }
60
- expect.assertions(1)
61
- return expect(validate(mangled)).rejects.toMatchObject([
62
- { keyword: 'Invalid protocol schema requested' },
63
- ])
64
- })
65
- it('should fail validation with a mangled command schema spec', () => {
66
- const mangled = { ...base, commandSchemaId: 'asdasd' }
67
- return expect(validate(mangled)).rejects.toMatchObject([
68
- { keyword: 'Invalid command schema requested' },
69
- ])
70
- })
71
- it('should fail validation with a mangled liquid schema spec', () => {
72
- const mangled = { ...base, liquidSchemaId: 'asdhasdas' }
73
- return expect(validate(mangled)).rejects.toMatchObject([
74
- { keyword: 'Invalid liquid schema requested' },
75
- ])
76
- })
77
- it('should fail validation with a mangled command annotation schema spec', () => {
78
- const mangled = { ...base, commandAnnotationSchemaId: 'asdasd' }
79
- return expect(validate(mangled)).rejects.toMatchObject([
80
- { keyword: 'Invalid command annotation schema requested' },
81
- ])
82
- })
83
- })
@@ -1,40 +0,0 @@
1
- import { sortWells } from '../helpers'
2
-
3
- describe('sortWells', () => {
4
- it('single letters', () => {
5
- const input = ['A12', 'A2', 'B1', 'B12', 'A1']
6
- const expected = ['A1', 'B1', 'A2', 'A12', 'B12']
7
- const result = [...input].sort(sortWells)
8
- expect(result).toEqual(expected)
9
- })
10
-
11
- // just in case we get a 1536-well plate
12
- it('double letters', () => {
13
- const input = [
14
- 'AB12',
15
- 'A12',
16
- 'B12',
17
- 'Z12',
18
- 'AA12',
19
- 'AB1',
20
- 'Z1',
21
- 'A1',
22
- 'B1',
23
- 'AA1',
24
- ]
25
- const expected = [
26
- 'A1',
27
- 'B1',
28
- 'Z1',
29
- 'AA1',
30
- 'AB1',
31
- 'A12',
32
- 'B12',
33
- 'Z12',
34
- 'AA12',
35
- 'AB12',
36
- ]
37
- const result = [...input].sort(sortWells)
38
- expect(result).toEqual(expected)
39
- })
40
- })
@@ -1,21 +0,0 @@
1
- import { splitWellsOnColumn } from '../helpers'
2
-
3
- describe('test splitWellsOnColumn', () => {
4
- it('empty array', () => {
5
- expect(splitWellsOnColumn([])).toEqual([])
6
- })
7
-
8
- it('one value', () => {
9
- expect(splitWellsOnColumn(['A1'])).toEqual([['A1']])
10
- })
11
-
12
- it('sort multi-digit wels', () => {
13
- expect(splitWellsOnColumn(['A1', 'B2', 'C2', 'D3', 'X10', 'X11'])).toEqual([
14
- ['A1'],
15
- ['B2', 'C2'],
16
- ['D3'],
17
- ['X10'],
18
- ['X11'],
19
- ])
20
- })
21
- })
@@ -1,34 +0,0 @@
1
- // Tests for error data validation
2
-
3
- import Ajv from 'ajv'
4
-
5
- import errorDefinitions from '@opentrons/shared-data/errors/definitions/1/errors.json'
6
- import errorSchema from '@opentrons/shared-data/errors/schemas/1.json'
7
-
8
- describe('error data should match error schema', () => {
9
- it('error schema should match', () => {
10
- const ajv = new Ajv({ allErrors: true })
11
- const validator = ajv.compile(errorSchema)
12
- const valid = validator(errorDefinitions)
13
- const validationFailures = validator.errors
14
- if (validationFailures) {
15
- console.log(
16
- 'errors.json does not follow its schema',
17
- JSON.stringify(validationFailures, null, 4)
18
- )
19
- }
20
- expect(valid).toBe(true)
21
- expect(validationFailures).toBeNull()
22
- })
23
- })
24
-
25
- describe('error code unschemad requirements should match', () =>
26
- Object.entries(errorDefinitions.codes).forEach(
27
- ([errorCode, { category: errorCategory }]) => {
28
- it(`error code ${errorCode} category is correct`, () => {
29
- const categoryObj = errorDefinitions.categories[errorCategory] ?? null
30
- expect(categoryObj).not.toBeNull()
31
- expect(errorCode).toMatch(new RegExp(`^${categoryObj.codePrefix}.*$`))
32
- })
33
- }
34
- ))