Add more tests

pull/1174/head
Rick Carlino 2019-04-30 17:10:23 -05:00
parent d5bd13099b
commit 0b73a17ef9
3 changed files with 27 additions and 22 deletions

View File

@ -127,10 +127,8 @@ module Devices
s.dig(:body, 4, :args, :location, :args)[:tool_id] = seed_bin_id
Sequences::Create.run!(s, device: device)
when ProductLines::EXPRESS
raise "TODO"
when ProductLines::NONE
return
# when ProductLines::EXPRESS then raise "TODO"
when ProductLines::NONE then return
end
end
@ -194,10 +192,10 @@ module Devices
device.firmware_config.update_attributes!(encoder_enabled_x: 1,
encoder_enabled_y: 1,
encoder_enabled_z: 1)
when ProductLines::EXPRESS
device.firmware_config.update_attributes!(encoder_enabled_x: 0,
encoder_enabled_y: 0,
encoder_enabled_z: 0)
# when ProductLines::EXPRESS
# device.firmware_config.update_attributes!(encoder_enabled_x: 0,
# encoder_enabled_y: 0,
# encoder_enabled_z: 0)
when ProductLines::NONE
return
end
@ -263,10 +261,6 @@ module Devices
Tools::Create.run!(name: name, device: device)
end
def build_tools_first
raise "TODO - need to implement tools first!"
end
def add_peripheral(pin, label)
Peripherals::Create.run!(device: device,
pin: pin,

View File

@ -38,17 +38,17 @@ module Devices
# Stub sequences ===========================
SEQUENCE_FIXTURE_PATH =
"app/mutations/devices/seeders/sequence_fixtures.yml"
SEQUENCES = YAML.load(File.read(SEQUENCE_FIXTURE_PATH))
module SequenceSeeds
MOUNT_TOOL = SEQUENCES.fetch(:MOUNT_TOOL)
PICK_UP_SEED_EXPRESS = SEQUENCES.fetch(:PICK_UP_SEED_EXPRESS)
PICK_UP_SEED_GENESIS = SEQUENCES.fetch(:PICK_UP_SEED_GENESIS)
PLANT_SEED = SEQUENCES.fetch(:PLANT_SEED)
TAKE_PHOTO_OF_PLANT = SEQUENCES.fetch(:TAKE_PHOTO_OF_PLANT)
TOOL_ERROR = SEQUENCES.fetch(:TOOL_ERROR)
UNMOUNT_TOOL = SEQUENCES.fetch(:UNMOUNT_TOOL)
WATER_PLANT = SEQUENCES.fetch(:WATER_PLANT)
ALL = YAML.load(File.read(SEQUENCE_FIXTURE_PATH))
MOUNT_TOOL = ALL.fetch(:MOUNT_TOOL)
PICK_UP_SEED_EXPRESS = ALL.fetch(:PICK_UP_SEED_EXPRESS)
PICK_UP_SEED_GENESIS = ALL.fetch(:PICK_UP_SEED_GENESIS)
PLANT_SEED = ALL.fetch(:PLANT_SEED)
TAKE_PHOTO_OF_PLANT = ALL.fetch(:TAKE_PHOTO_OF_PLANT)
TOOL_ERROR = ALL.fetch(:TOOL_ERROR)
UNMOUNT_TOOL = ALL.fetch(:UNMOUNT_TOOL)
WATER_PLANT = ALL.fetch(:WATER_PLANT)
end
end
end

View File

@ -71,7 +71,18 @@ describe Api::DevicesController do
.map { |x| expect(tool_names).to include(x) }
expect(device.sequences.count).to eq(7)
binding.pry # Now what?
sequence_names = device.sequences.pluck(:name)
expect(sequence_names).not_to include("Pick up seed (Express)")
[
"Mount tool",
"Pick up seed (Genesis)",
"Plant seed",
"Take photo of plant",
"Tool error",
"Unmount tool",
"Water plant",
].map { |x| expect(sequence_names).to include(x) }
end
end
end