Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Y24-190-3 Use API v2 TagLayout #1901

Merged
merged 5 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pryrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true
if defined?(PryByebug)
BenTopping marked this conversation as resolved.
Show resolved Hide resolved
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.commands.alias_command 'f', 'finish'
Pry.commands.alias_command 'c', 'continue'
end
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ describe('CustomTaggedPlate', () => {
purpose_uuid: 'purpose-uuid',
parent_uuid: 'parent-plate-uuid',
tag_layout: {
tag_group: 'tag-1-group-uuid',
tag2_group: 'tag-2-group-uuid',
tag_group_uuid: 'tag-1-group-uuid',
tag2_group_uuid: 'tag-2-group-uuid',
direction: 'column',
walking_by: 'manual by plate',
initial_tag: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ export default {
purpose_uuid: this.purposeUuid,
parent_uuid: this.parentUuid,
tag_layout: {
tag_group: this.tag1GroupUuid,
tag2_group: this.tag2GroupUuid,
tag_group_uuid: this.tag1GroupUuid,
tag2_group_uuid: this.tag2GroupUuid,
direction: this.direction,
walking_by: this.walkingBy,
initial_tag: initialTag,
Expand Down
12 changes: 7 additions & 5 deletions app/models/labware_creators/custom_tagged_plate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class CustomTaggedPlate < Base
{
tag_plate: %i[asset_uuid template_uuid state],
tag_layout: [
:user,
:plate,
:tag_group,
:tag2_group,
:user_uuid,
:plate_uuid,
:tag_group_uuid,
:tag2_group_uuid,
:direction,
:walking_by,
:initial_tag,
Expand Down Expand Up @@ -107,7 +107,9 @@ def tag_layout_attributes

def create_labware!
create_plate! do |plate_uuid|
api.tag_layout.create!(tag_layout_attributes.merge(plate: plate_uuid, user: user_uuid))
Sequencescape::Api::V2::TagLayout.create!(
tag_layout_attributes.merge(plate_uuid: plate_uuid, user_uuid: user_uuid)
)
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions app/sequencescape/sequencescape/api/v2/tag_layout.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

# tag layout resource
class Sequencescape::Api::V2::TagLayout < Sequencescape::Api::V2::Base
end
85 changes: 44 additions & 41 deletions spec/models/labware_creators/custom_tagged_plate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,48 @@

let(:expected_transfers) { WellHelpers.stamp_hash(96) }

def expect_transfer_creation
def expect_state_change_creation
expect_api_v2_posts(
'Transfer',
'StateChange',
[
{
reason: 'Used in Library creation',
target_uuid: tag_plate_uuid,
target_state: 'exhausted',
user_uuid: user_uuid
}
]
)
end

def expect_tag_layout_creation
expect_api_v2_posts(
'TagLayout',
[
{
user_uuid: user_uuid,
source_uuid: plate_uuid,
destination_uuid: child_plate_uuid,
transfer_template_uuid: transfer_template_uuid,
transfers: expected_transfers
plate_uuid: child_plate_uuid,
tag_group_uuid: 'tag-group-uuid',
tag2_group_uuid: 'tag2-group-uuid',
direction: 'column',
walking_by: 'manual by plate',
initial_tag: '1',
tags_per_well: 1
}
]
)
end

def expect_state_change_creation
def expect_transfer_creation
expect_api_v2_posts(
'StateChange',
'Transfer',
[
{
reason: 'Used in Library creation',
target_uuid: tag_plate_uuid,
target_state: 'exhausted',
user_uuid: user_uuid
user_uuid: user_uuid,
source_uuid: plate_uuid,
destination_uuid: child_plate_uuid,
transfer_template_uuid: transfer_template_uuid,
transfers: expected_transfers
}
]
)
Expand All @@ -157,9 +175,9 @@ def expect_state_change_creation
state: tag_plate_state
},
tag_layout: {
user: 'user-uuid',
tag_group: 'tag-group-uuid',
tag2_group: 'tag2-group-uuid',
user_uuid: 'user-uuid',
tag_group_uuid: 'tag-group-uuid',
tag2_group_uuid: 'tag2-group-uuid',
direction: 'column',
walking_by: 'manual by plate',
initial_tag: '1',
Expand All @@ -176,37 +194,20 @@ def expect_state_change_creation
it_behaves_like 'it has a custom page', 'custom_tagged_plate'

context 'on save' do
let!(:custom_tag_layout_creation_request) do
stub_api_post(
'tag_layouts',
payload: {
tag_layout: {
user: 'user-uuid',
plate: child_plate_uuid,
tag_group: 'tag-group-uuid',
tag2_group: 'tag2-group-uuid',
direction: 'column',
walking_by: 'manual by plate',
initial_tag: '1',
tags_per_well: 1
}
}
)
end

context 'with an available tag plate' do
let(:tag_plate_state) { 'available' }

it 'creates a tag plate' do
expect_transfer_creation
expect_state_change_creation
expect_tag_layout_creation
expect_transfer_creation

expect(subject.save).to be true
expect(plate_creation_request).to have_been_made.once
expect(custom_tag_layout_creation_request).to have_been_made.once
end

it 'has the correct child (and uuid)' do
stub_api_v2_post('TagLayout')
stub_api_v2_post('Transfer')
stub_api_v2_post('StateChange')

Expand All @@ -218,12 +219,12 @@ def expect_state_change_creation

context 'when a user has exhausted the plate in another tab' do
it 'creates a tag plate' do
expect_transfer_creation
expect_state_change_creation
expect_tag_layout_creation
expect_transfer_creation

expect(subject.save).to be true
expect(plate_creation_request).to have_been_made.once
expect(custom_tag_layout_creation_request).to have_been_made.once
end
end
end
Expand All @@ -232,17 +233,18 @@ def expect_state_change_creation
let(:tag_plate_state) { 'exhausted' }

it 'creates a tagged plate' do
# This one will be VERY different
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it came from removed line 241 below and I'm making the same expectation, just via API V2, so hopefully it's intentional.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah just not sure what the difference is that the comment is suggesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. I didn't want to try to clean up existing comments and I assumed it was made for a reason. It's very easy to put in comments that aren't useful in the future 😄

expect_tag_layout_creation

expect_transfer_creation
expect(Sequencescape::Api::V2::StateChange).not_to receive(:create!)

expect(subject.save).to be true
expect(plate_creation_request).to have_been_made.once

# This one will be VERY different
expect(custom_tag_layout_creation_request).to have_been_made.once
end

it 'has the correct child (and uuid)' do
stub_api_v2_post('TagLayout')
stub_api_v2_post('Transfer')

expect(subject.save).to be true
Expand All @@ -258,15 +260,16 @@ def expect_state_change_creation
let(:parents) { [plate_uuid] }

it 'creates a tag plate' do
expect_tag_layout_creation
expect_transfer_creation
expect(Sequencescape::Api::V2::StateChange).not_to receive(:create!)

expect(subject.save).to be true
expect(plate_creation_request).to have_been_made.once
expect(custom_tag_layout_creation_request).to have_been_made.once
end

it 'has the correct child (and uuid)' do
stub_api_v2_post('TagLayout')
stub_api_v2_post('Transfer')

expect(subject.save).to be true
Expand Down
Loading