Skip to content

Commit aec8431

Browse files
committed
Add tests for brick default model selection and compatible models
1 parent b4b1d92 commit aec8431

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

internal/orchestrator/bricks/bricks_test.go

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,21 @@ func TestAppBrickInstancesList(t *testing.T) {
733733

734734
svc := &Service{
735735
bricksIndex: bIndex,
736-
modelsIndex: &modelsindex.ModelsIndex{},
736+
modelsIndex: &modelsindex.ModelsIndex{
737+
Models: []modelsindex.AIModel{
738+
{
739+
ID: "yolox-object-detection",
740+
Name: "General purpose object detection - YoloX",
741+
ModuleDescription: "a-model-description",
742+
Bricks: []string{"arduino:object_detection"},
743+
},
744+
{
745+
ID: "face-detection",
746+
Name: "Lightweight-Face-Detection",
747+
Bricks: []string{"arduino:object_detection"},
748+
},
749+
},
750+
},
737751
}
738752

739753
tests := []struct {
@@ -809,6 +823,10 @@ func TestAppBrickInstancesList(t *testing.T) {
809823
require.Equal(t, "video", brick.Category)
810824
require.True(t, brick.RequireModel)
811825
require.Equal(t, "face-detection", brick.ModelID)
826+
require.Equal(t, []AIModel{
827+
{ID: "yolox-object-detection", Name: "General purpose object detection - YoloX", Description: "a-model-description"},
828+
{ID: "face-detection", Name: "Lightweight-Face-Detection", Description: ""},
829+
}, brick.CompatibleModels)
812830

813831
foundCustom := false
814832
for _, v := range brick.ConfigVariables {
@@ -820,6 +838,30 @@ func TestAppBrickInstancesList(t *testing.T) {
820838
require.True(t, foundCustom, "Variable CUSTOM_MODEL_PATH should be present and overridden")
821839
},
822840
},
841+
{
842+
name: "Success - Brick using brick default model",
843+
app: &app.ArduinoApp{
844+
Descriptor: app.AppDescriptor{
845+
Bricks: []app.Brick{
846+
{
847+
ID: "arduino:object_detection",
848+
},
849+
},
850+
},
851+
},
852+
validate: func(t *testing.T, res AppBrickInstancesResult) {
853+
require.Len(t, res.BrickInstances, 1)
854+
brick := res.BrickInstances[0]
855+
856+
require.Equal(t, "arduino:object_detection", brick.ID)
857+
require.True(t, brick.RequireModel)
858+
require.Equal(t, "yolox-object-detection", brick.ModelID)
859+
require.Equal(t, []AIModel{
860+
{ID: "yolox-object-detection", Name: "General purpose object detection - YoloX", Description: "a-model-description"},
861+
{ID: "face-detection", Name: "Lightweight-Face-Detection", Description: ""},
862+
}, brick.CompatibleModels)
863+
},
864+
},
823865
{
824866
name: "Success - Multiple Bricks",
825867
app: &app.ArduinoApp{

0 commit comments

Comments
 (0)