@@ -20,150 +20,12 @@ import (
2020 "testing"
2121
2222 "github.com/arduino/go-paths-helper"
23- yaml "github.com/goccy/go-yaml"
2423 "github.com/stretchr/testify/require"
2524)
2625
27- func TestBricksIndex (t * testing.T ) {
28- x := `bricks:
29- - id: arduino:image_classification
30- name: Image Classification
31- description: "Brick for image classification using a pre-trained model. It processes\
32- \ images and returns the predicted class label and confidence score.\nBrick is\
33- \ designed to work with pre-trained models provided by framework or with custom\
34- \ image classification models trained on Edge Impulse platform. \n"
35- require_container: true
36- require_model: true
37- ports: []
38- model_name: mobilenet-image-classification
39- variables:
40- - name: CUSTOM_MODEL_PATH
41- default_value: /opt/models/ei/
42- description: path to the custom model directory
43- - name: EI_CLASSIFICATION_MODEL
44- default_value: /models/ootb/ei/mobilenet-v2-224px.eim
45- description: path to the model file
46- - id: arduino:camera_scanner
47- name: Camera Scanner
48- description: Scans a camera for barcodes and QR codes
49- require_container: false
50- require_model: false
51- ports: []
52- - id: arduino:streamlit_ui
53- name: Streamlit UI
54- description: A simplified user interface based on Streamlit and Python.
55- require_container: false
56- require_model: false
57- ports:
58- - 7000
59- - id: arduino:keyword_spotter
60- name: Keyword Spotter
61- description: 'Brick for keyword spotting using a pre-trained model. It processes
62- audio input to detect specific keywords or phrases.
63-
64- Brick is designed to work with pre-trained models provided by framework or with
65- custom audio classification models trained on Edge Impulse platform.
66-
67- '
68- require_container: true
69- require_model: true
70- ports: []
71- model_name: keyword-spotting-hello-world
72- variables:
73- - name: CUSTOM_MODEL_PATH
74- default_value: /opt/models/ei/
75- description: path to the custom model directory
76- - name: EI_KEYWORK_SPOTTING_MODEL
77- default_value: /models/ootb/ei/keyword-spotting-hello-world.eim
78- description: path to the model file
79- - id: arduino:mqtt
80- name: MQTT Connector
81- description: MQTT connector module. Acts as a client for receiving and publishing
82- messages to an MQTT broker.
83- require_container: false
84- require_model: false
85- ports: []
86- - id: arduino:web_ui
87- name: Web UI
88- description: A user interface based on HTML and JavaScript that can rely on additional
89- APIs and a WebSocket exposed by a web server.
90- require_container: false
91- require_model: false
92- ports:
93- - 7000
94- - id: arduino:dbstorage_tsstore
95- name: Database Storage - Time Series Store
96- description: Simplified time series database storage layer for Arduino sensor samples
97- built on top of InfluxDB.
98- require_container: true
99- require_model: false
100- ports: []
101- variables:
102- - name: APP_HOME
103- default_value: .
104- - name: DB_PASSWORD
105- default_value: Arduino15
106- description: Database password
107- - name: DB_USERNAME
108- default_value: admin
109- description: Edge Impulse project API key
110- - name: INFLUXDB_ADMIN_TOKEN
111- default_value: 392edbf2-b8a2-481f-979d-3f188b2c05f0
112- description: InfluxDB admin token
113- - id: arduino:dbstorage_sqlstore
114- name: Database Storage - SQLStore
115- description: Simplified database storage layer for Arduino sensor data using SQLite
116- local database.
117- require_container: false
118- require_model: false
119- ports: []
120- - id: arduino:object_detection
121- name: Object Detection
122- description: "Brick for object detection using a pre-trained model. It processes\
123- \ images and returns the predicted class label, bounding-boxes and confidence\
124- \ score.\nBrick is designed to work with pre-trained models provided by framework\
125- \ or with custom object detection models trained on Edge Impulse platform. \n"
126- require_container: true
127- require_model: true
128- ports: []
129- model_name: yolox-object-detection
130- variables:
131- - name: CUSTOM_MODEL_PATH
132- default_value: /opt/models/ei/
133- description: path to the custom model directory
134- - name: EI_OBJ_DETECTION_MODEL
135- default_value: /models/ootb/ei/yolo-x-nano.eim
136- description: path to the model file
137- - id: arduino:weather_forecast
138- name: Weather Forecast
139- description: Online weather forecast module for Arduino using open-meteo.com geolocation
140- and weather APIs. Requires an internet connection.
141- require_container: false
142- require_model: false
143- ports: []
144- - id: arduino:visual_anomaly_detection
145- name: Visual Anomaly Detection
146- description: "Brick for visual anomaly detection using a pre-trained model. It processes\
147- \ images and returns detected anomalies and bounding-boxes.\nBrick is designed\
148- \ to work with pre-trained models provided by framework or with custom object\
149- \ detection models trained on Edge Impulse platform. \n"
150- require_container: true
151- require_model: true
152- ports: []
153- model_name: concreate-crack-anomaly-detection
154- variables:
155- - name: CUSTOM_MODEL_PATH
156- default_value: /opt/models/ei/
157- description: path to the custom model directory
158- - name: EI_V_ANOMALY_DETECTION_MODEL
159- default_value: /models/ootb/ei/concrete-crack-anomaly-detection.eim
160- description: path to the model file
161- `
162-
163- var index BricksIndex
164- err := yaml .Unmarshal ([]byte (x ), & index )
26+ func TestGenerateBricksIndexFromFile (t * testing.T ) {
27+ index , err := GenerateBricksIndexFromFile (paths .New ("testdata" ))
16528 require .NoError (t , err )
166- require .Len (t , index .Bricks , 11 )
16729
16830 // Check if ports are correctly set
16931 b , found := index .FindBrickByID ("arduino:web_ui" )
@@ -195,13 +57,13 @@ func TestBricksIndexYAMLFormats(t *testing.T) {
19557 expectedBricks []Brick
19658 }{
19759 {
198- // TODO: the validator of the brick -list must not allow this
60+ // TODO: add a validator fo the bricks -list to validate the field
19961 name : "missing bricks field does not cuase error" ,
20062 yamlContent : `other_field: value` ,
20163 expectedBricks : nil ,
20264 },
20365 {
204- name : "bad YAML format - invalid indentation" ,
66+ name : "bad YAML format invalid indentation" ,
20567 yamlContent : `bricks:
20668 - id: arduino:test_brick
20769 name: Test Brick
@@ -214,22 +76,22 @@ func TestBricksIndexYAMLFormats(t *testing.T) {
21476 expectedBricks : []Brick {},
21577 },
21678 {
217- name : "bad YAML format - unclosed quotes" ,
79+ name : "bad YAML format unclosed quotes" ,
21880 yamlContent : `bricks:
21981- id: "arduino:test_brick
22082 name: Test Brick
22183 description: A test brick` ,
22284 expectedError : "could not find end character of double-quoted text" ,
22385 },
22486 {
225- name : "bad YAML format - missing colon" ,
87+ name : "bad YAML format missing colon" ,
22688 yamlContent : `bricks:
22789- id arduino:test_brick
22890 name: Test Brick` ,
22991 expectedError : "unexpected key name" ,
23092 },
23193 {
232- name : "bad YAML format - invalid syntax" ,
94+ name : "bad YAML format invalid syntax" ,
23395 yamlContent : `bricks:
23496- id: arduino:test_brick
23597 name: Test Brick
@@ -238,7 +100,7 @@ func TestBricksIndexYAMLFormats(t *testing.T) {
238100 expectedError : "sequence end token ']' not found" ,
239101 },
240102 {
241- name : "bad YAML format - tab characters" ,
103+ name : "bad YAML format tab characters" ,
242104 yamlContent : "bricks:\n \t - id: arduino:test_brick\n \t name: Test Brick" ,
243105 expectedError : "found character '\t ' that cannot start any token" ,
244106 },
0 commit comments