Fix blinky test
parent
026eca4a4d
commit
ac6e5387b3
|
@ -74,9 +74,8 @@ module CeleryScriptSettingsBag
|
||||||
"BoxLed4" => BoxLed }
|
"BoxLed4" => BoxLed }
|
||||||
CANT_ANALOG = "Analog modes are not supported for Box LEDs"
|
CANT_ANALOG = "Analog modes are not supported for Box LEDs"
|
||||||
ALLOWED_PIN_TYPES = PIN_TYPE_MAP.keys
|
ALLOWED_PIN_TYPES = PIN_TYPE_MAP.keys
|
||||||
KLASS_LOOKUP = Point::POINTER_KINDS.reduce({}) do |acc, val|
|
# KLASS_LOOKUP =
|
||||||
(acc[val] = Kernel.const_get(val)) && acc
|
# Point::POINTER_KINDS.reduce({}) { |a, v| (a[v] = Kernel.const_get(v)) && a }
|
||||||
end
|
|
||||||
RESOURCE_UPDATE_ARGS = [:resource_type, :resource_id, :label, :value]
|
RESOURCE_UPDATE_ARGS = [:resource_type, :resource_id, :label, :value]
|
||||||
|
|
||||||
Corpus = CeleryScript::Corpus
|
Corpus = CeleryScript::Corpus
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe CeleryScript::Corpus do
|
||||||
speed: 100
|
speed: 100
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
check1 = CeleryScript::Checker.new(ok1, Sequence::Corpus, device)
|
check1 = CeleryScript::Checker.new(ok1, corpus, device)
|
||||||
expect(check1.valid?).to be_truthy
|
expect(check1.valid?).to be_truthy
|
||||||
|
|
||||||
ok2 = CeleryScript::AstNode.new({
|
ok2 = CeleryScript::AstNode.new({
|
||||||
|
@ -48,7 +48,7 @@ describe CeleryScript::Corpus do
|
||||||
speed: 100
|
speed: 100
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
check2 = CeleryScript::Checker.new(ok2, Sequence::Corpus, device)
|
check2 = CeleryScript::Checker.new(ok2, corpus, device)
|
||||||
expect(check2.valid?).to be_truthy
|
expect(check2.valid?).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ describe CeleryScript::Corpus do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
check = CeleryScript::Checker.new(bad, Sequence::Corpus, device)
|
check = CeleryScript::Checker.new(bad, corpus, device)
|
||||||
expect(check.valid?).to be_falsey
|
expect(check.valid?).to be_falsey
|
||||||
expect(check.error.message).to include("but got Integer")
|
expect(check.error.message).to include("but got Integer")
|
||||||
expect(check.error.message).to include("'location' within 'move_absolute'")
|
expect(check.error.message).to include("'location' within 'move_absolute'")
|
||||||
|
@ -94,7 +94,7 @@ describe CeleryScript::Corpus do
|
||||||
speed: 100
|
speed: 100
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
check = CeleryScript::Checker.new(bad, Sequence::Corpus, device)
|
check = CeleryScript::Checker.new(bad, corpus, device)
|
||||||
expect(check.valid?).to be_falsey
|
expect(check.valid?).to be_falsey
|
||||||
expect(check.error.message).to include("but got String")
|
expect(check.error.message).to include("but got String")
|
||||||
end
|
end
|
||||||
|
@ -123,9 +123,7 @@ describe CeleryScript::Corpus do
|
||||||
},
|
},
|
||||||
"body": []
|
"body": []
|
||||||
})
|
})
|
||||||
checker = CeleryScript::Checker.new(tree,
|
checker = CeleryScript::Checker.new(tree, corpus, device)
|
||||||
CeleryScriptSettingsBag::Corpus,
|
|
||||||
device)
|
|
||||||
expect(checker.error.message).to include("not a valid message_type")
|
expect(checker.error.message).to include("not a valid message_type")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,9 +143,32 @@ describe CeleryScript::Corpus do
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
checker = CeleryScript::Checker.new(tree,
|
checker = CeleryScript::Checker.new(tree, corpus, device)
|
||||||
CeleryScriptSettingsBag::Corpus,
|
|
||||||
device)
|
|
||||||
expect(checker.error.message).to include("not a valid channel_name")
|
expect(checker.error.message).to include("not a valid channel_name")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "validates tool_ids" do
|
||||||
|
ast = { "kind": "tool", "args": { "tool_id": 0 } };
|
||||||
|
checker = CeleryScript::Checker.new(CeleryScript::AstNode.new(ast),
|
||||||
|
corpus,
|
||||||
|
device)
|
||||||
|
expect(checker.valid?).to be(false)
|
||||||
|
expect(checker.error.message).to include("Tool #0 does not exist.")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "Validates resource_update nodes" do
|
||||||
|
ast = {
|
||||||
|
kind: "resource_update",
|
||||||
|
args: {
|
||||||
|
resource_type: "Device",
|
||||||
|
resource_id: 23,
|
||||||
|
label: "mounted_tool_id",
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ast = { "kind": "tool", "args": { "tool_id": 0 } };
|
||||||
|
checker = CeleryScript::Checker.new(CeleryScript::AstNode.new(ast),
|
||||||
|
corpus,
|
||||||
|
device)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ end
|
||||||
|
|
||||||
describe "Pin Binding updates" do
|
describe "Pin Binding updates" do
|
||||||
it "enforces mutual exclusivity" do
|
it "enforces mutual exclusivity" do
|
||||||
Device.destroy_all
|
Device.update_all(mounted_tool_id: nil)
|
||||||
[Point, Tool, PinBinding, Sequence].map(&:destroy_all)
|
[Point, Tool, PinBinding, Sequence].map(&:destroy_all)
|
||||||
device = FactoryBot.create(:device)
|
device = FactoryBot.create(:device)
|
||||||
PinBinding.create!(device: device)
|
PinBinding.create!(device: device)
|
||||||
|
|
Loading…
Reference in New Issue