Skip to content

Commit

Permalink
ci: mock server for imagga api
Browse files Browse the repository at this point in the history
  • Loading branch information
gbicou committed Nov 21, 2024
1 parent 15d5f3c commit 9a81884
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
PUBLIC_URL="http://127.0.0.1:8055"
ADMIN_EMAIL="test@test.com"
ADMIN_PASSWORD="test"
ADMIN_TOKEN="test"
PUBLIC_URL="http://127.0.0.1:8055"
IMAGGA_API="http://imagga:1080"
10 changes: 10 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ services:
volumes:
- ./:/directus/extensions/imagga
env_file: ".env.test"
imagga:
image: mockserver/mockserver:5.15.0
ports:
- 1080:1080
environment:
MOCKSERVER_PROPERTY_FILE: /mocks/mockserver.properties
MOCKSERVER_INITIALIZATION_JSON_PATH: /mocks/imagga.json
MOCKSERVER_WATCH_INITIALIZATION_JSON: "true"
volumes:
- ./mocks:/mocks
199 changes: 199 additions & 0 deletions mocks/imagga.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
[
{
"httpRequest": {
"method": "POST",
"path": "/uploads"
},
"httpResponse": {
"statusCode": 200,
"body": {
"result": {
"upload_id": "i05e132196706b94b1d85efb5f3SaM1j"
},
"status": {
"text": "",
"type": "success"
}
}
}
},
{
"httpRequest": {
"method": "GET",
"path": "/tags",
"query": {
"image_upload_id": "i05e132196706b94b1d85efb5f3SaM1j"
}
},
"httpResponse": {
"statusCode": 200,
"body": {
"result": {
"tags": [
{
"confidence": 61.4116096496582,
"tag": {
"en": "mountain"
}
},
{
"confidence": 54.3507270812988,
"tag": {
"en": "landscape"
}
}
]
},
"status": {
"text": "",
"type": "success"
}
}
}
},
{
"httpRequest": {
"method": "GET",
"path": "/colors",
"query": {
"image_upload_id": "i05e132196706b94b1d85efb5f3SaM1j"
}
},
"httpResponse": {
"statusCode": 200,
"body": {
"result": {
"colors": {
"background_colors": [
{
"b": 47,
"closest_palette_color": "light bronze",
"closest_palette_color_html_code": "#8c5e37",
"closest_palette_color_parent": "skin",
"closest_palette_distance": 1.70506228322597,
"g": 92,
"html_code": "#8c5c2f",
"percent": 48.0033950805664,
"r": 140
},
{
"b": 146,
"closest_palette_color": "cerulean",
"closest_palette_color_html_code": "#0074a8",
"closest_palette_color_parent": "blue",
"closest_palette_distance": 5.53350780052479,
"g": 116,
"html_code": "#467492",
"percent": 39.0454025268555,
"r": 70
},
{
"b": 30,
"closest_palette_color": "dark bronze",
"closest_palette_color_html_code": "#542e0c",
"closest_palette_color_parent": "skin",
"closest_palette_distance": 5.47689735887696,
"g": 48,
"html_code": "#4f301e",
"percent": 12.9512014389038,
"r": 79
}
],
"color_percent_threshold": 1.75,
"color_variance": 36,
"foreground_colors": [
{
"b": 147,
"closest_palette_color": "larkspur",
"closest_palette_color_html_code": "#6e7e99",
"closest_palette_color_parent": "blue",
"closest_palette_distance": 8.60114706674971,
"g": 125,
"html_code": "#577d93",
"percent": 52.3429222106934,
"r": 87
},
{
"b": 145,
"closest_palette_color": "pewter",
"closest_palette_color_html_code": "#84898c",
"closest_palette_color_parent": "grey",
"closest_palette_distance": 1.75501013175431,
"g": 142,
"html_code": "#898e91",
"percent": 30.0293598175049,
"r": 137
},
{
"b": 42,
"closest_palette_color": "brownie",
"closest_palette_color_html_code": "#584039",
"closest_palette_color_parent": "brown",
"closest_palette_distance": 4.99189248709017,
"g": 58,
"html_code": "#593a2a",
"percent": 17.6277160644531,
"r": 89
}
],
"image_colors": [
{
"b": 146,
"closest_palette_color": "cerulean",
"closest_palette_color_html_code": "#0074a8",
"closest_palette_color_parent": "blue",
"closest_palette_distance": 7.85085588656478,
"g": 121,
"html_code": "#547992",
"percent": 48.3686981201172,
"r": 84
},
{
"b": 46,
"closest_palette_color": "light bronze",
"closest_palette_color_html_code": "#8c5e37",
"closest_palette_color_parent": "skin",
"closest_palette_distance": 3.05634270891355,
"g": 86,
"html_code": "#83562e",
"percent": 47.9353446960449,
"r": 131
},
{
"b": 46,
"closest_palette_color": "navy blue",
"closest_palette_color_html_code": "#2b2e43",
"closest_palette_color_parent": "navy blue",
"closest_palette_distance": 6.62790662069936,
"g": 27,
"html_code": "#1f1b2e",
"percent": 3.60131478309631,
"r": 31
}
],
"object_percentage": 20.790994644165
}
},
"status": {
"text": "",
"type": "success"
}
}
}
},
{
"httpRequest": {
"method": "DELETE",
"path": "/uploads/i05e132196706b94b1d85efb5f3SaM1j"
},
"httpResponse": {
"statusCode": 200,
"body": {
"status": {
"text": "",
"type": "success"
}
}
}
}
]
Empty file added mocks/mockserver.properties
Empty file.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"dotenv": "16.4.5",
"eslint": "9.15.0",
"eslint-plugin-unicorn": "56.0.1",
"mockserver-client": "5.15.0",
"rollup-plugin-node-externals": "7.1.3",
"typescript": "5.6.3",
"typescript-eslint": "8.15.0",
Expand Down
Loading

0 comments on commit 9a81884

Please sign in to comment.