-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from developmentseed/enhance/cypress-api
Move mock API routes payloads into separate files
- Loading branch information
Showing
47 changed files
with
1,075 additions
and
1,218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { interceptHostname, interceptUrl, interceptApiRoute } from './utils'; | ||
|
||
import apiIndex from '../mock-api-routes/fixtures/index.json'; | ||
import apiHealth from '../mock-api-routes/fixtures/health.json'; | ||
import imageryIndex from '../mock-api-routes/fixtures/imagery.json'; | ||
import mosaicIndex from '../mock-api-routes/fixtures/mosaic/index.json'; | ||
import mosaicNaipLatest from '../mock-api-routes/fixtures/mosaic/naip.latest.json'; | ||
|
||
const restApiEndpoint = Cypress.config('restApiEndpoint'); | ||
|
||
Cypress.Commands.add('mockCommonApiRoutes', () => { | ||
// OSM Tiles | ||
['a', 'b', 'c'].forEach((subdomain) => { | ||
interceptHostname(`${subdomain}.tile.openstreetmap.org`, { | ||
fixture: 'tiles/osm-tile.png', | ||
}); | ||
}); | ||
|
||
// Fake Imagery Layer | ||
interceptUrl('https://tiles.lulc.ds.io/**', 'GET', { | ||
fixture: 'tiles/imagery-tile.png', | ||
}); | ||
|
||
// API Health | ||
interceptUrl(`${restApiEndpoint}/health`, 'GET', apiHealth); | ||
|
||
// API Limits | ||
interceptApiRoute('', 'GET', apiIndex); | ||
|
||
// Mosaic | ||
interceptApiRoute('mosaic/naip.latest', 'GET', mosaicNaipLatest); | ||
|
||
// Geocoder | ||
interceptUrl( | ||
'https://dev.virtualearth.net/REST/v1/Locations/*?*', | ||
'GET', | ||
{ fixture: 'geocoder/dc.json' }, | ||
'reverseGeocodeCity' | ||
); | ||
interceptUrl( | ||
'https://dev.virtualearth.net/REST/v1/Locations/40.36315736436661,-77.7938461303711?*', | ||
'GET', | ||
{ fixture: 'geocoder/rural.json' }, | ||
'reverseGeocodeRural' | ||
); | ||
|
||
// Imagery and Mosaic | ||
interceptApiRoute('imagery', 'GET', imageryIndex); | ||
interceptApiRoute('mosaic', 'GET', mosaicIndex); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "healthy": true, "message": "Good to go" } |
45 changes: 45 additions & 0 deletions
45
cypress/support/commands/mock-api-routes/fixtures/imagery.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"body": { | ||
"total": 2, | ||
"imagery_sources": [ | ||
{ | ||
"id": 1, | ||
"created": 1675835884757, | ||
"updated": 1675835884757, | ||
"name": "NAIP", | ||
"bounds": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[-180, -85.0511287798066], | ||
[-180, 85.0511287798066], | ||
[180, 85.0511287798066], | ||
[180, -85.0511287798066], | ||
[-180, -85.0511287798066] | ||
] | ||
], | ||
"bounds": [-180, -85.0511287798066, 180, 85.0511287798066] | ||
} | ||
}, | ||
{ | ||
"id": 2, | ||
"created": 1675866091377, | ||
"updated": 1675866091377, | ||
"name": "Sentinel-2", | ||
"bounds": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[-180, -85.0511287798066], | ||
[-180, 85.0511287798066], | ||
[180, 85.0511287798066], | ||
[180, -85.0511287798066], | ||
[-180, -85.0511287798066] | ||
] | ||
], | ||
"bounds": [-180, -85.0511287798066, 180, 85.0511287798066] | ||
} | ||
} | ||
] | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
cypress/support/commands/mock-api-routes/fixtures/index.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "1.0.0", | ||
"limits": { | ||
"live_inference": 10000000, | ||
"max_inference": 100000000, | ||
"instance_window": 600, | ||
"total_cpus": 15, | ||
"active_cpus": 5, | ||
"total_gpus": 15, | ||
"active_gpus": 5 | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
cypress/support/commands/mock-api-routes/fixtures/model/1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"id": 1, | ||
"created": 1636558577692, | ||
"active": true, | ||
"imagery_source_id": 1, | ||
"uid": 4, | ||
"name": "Midwest 7 Class", | ||
"meta": { | ||
"name": "Midwest 7 Class", | ||
"imagery": "NAIP", | ||
"f1_score": { | ||
"tree": 0.77, | ||
"grass": 0.72, | ||
"roads": 0.8, | ||
"water": 0.63, | ||
"bare soil": 0.16, | ||
"buildings": 0.73, | ||
"other impervious": 0.73 | ||
}, | ||
"description": "Midwest Combined multi-year", | ||
"f1_weighted": 0.738, | ||
"label_sources": "uvm", | ||
"training_area": 20802.340261, | ||
"training_data_aoi": "https://mvpmodels.blob.core.windows.net/midwest-multi-year/midwest_aoi.geojson", | ||
"class_distribution": { | ||
"tree": 0.43, | ||
"grass": 0.28, | ||
"roads": 0.06, | ||
"water": 0.01, | ||
"bare soil": 0.01, | ||
"buildings": 0.09, | ||
"other impervious": 0.13 | ||
}, | ||
"imagery_resolution": "100 cm" | ||
}, | ||
"classes": [ | ||
{ "name": "tree", "color": "#6CA966" }, | ||
{ "name": "grass", "color": "#D0F3AB" }, | ||
{ "name": "bare soil", "color": "#D2AD74" }, | ||
{ "name": "water", "color": "#486DA2" }, | ||
{ "name": "buildings", "color": "#F10100" }, | ||
{ "name": "roads", "color": "#FFC300" }, | ||
{ "name": "other impervious", "color": "#FF5733" } | ||
], | ||
"bounds": [ | ||
-83.25599304179488, | ||
41.246646145864226, | ||
-81.37080774185067, | ||
42.44198353133044 | ||
], | ||
"storage": true | ||
} |
47 changes: 47 additions & 0 deletions
47
cypress/support/commands/mock-api-routes/fixtures/model/2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"id": 2, | ||
"created": 1675854437985, | ||
"active": true, | ||
"imagery_source_id": 2, | ||
"uid": 41, | ||
"name": "srm-rm-model-02", | ||
"meta": { | ||
"imagery": "sentinel-2", | ||
"f1_score": { | ||
"Agua": 0.5, | ||
"Bosque": 0.5, | ||
"Pastos": 0.5, | ||
"Selvas": 0.5, | ||
"Urbano": 0.5, | ||
"Agricultura": 0.5, | ||
"Suelo desnudo": 0.5, | ||
"Sin vegetación aparente": 0.5 | ||
}, | ||
"description": "Sentinel Model test", | ||
"f1_weighted": 0.6, | ||
"label_sources": "RM", | ||
"class_distribution": { | ||
"Agua": 0.5, | ||
"Bosque": 0.5, | ||
"Pastos": 0.5, | ||
"Selvas": 0.5, | ||
"Urbano": 0.5, | ||
"Agricultura": 0.5, | ||
"Suelo desnudo": 0.5, | ||
"Sin vegetación aparente": 0.5 | ||
}, | ||
"imagery_resolution": "14" | ||
}, | ||
"classes": [ | ||
{ "name": "Bosque", "color": "#14d921" }, | ||
{ "name": "Selvas", "color": "#9aec3f" }, | ||
{ "name": "Pastos", "color": "#d8ec49" }, | ||
{ "name": "Agricultura", "color": "#f3e48b" }, | ||
{ "name": "Urbano", "color": "#f3f5f2" }, | ||
{ "name": "Sin vegetación aparente", "color": "#54d4d1" }, | ||
{ "name": "Agua", "color": "#2237d9" }, | ||
{ "name": "Suelo desnudo", "color": "#842ff8" } | ||
], | ||
"bounds": [-180, -90, 180, 90], | ||
"storage": true | ||
} |
Oops, something went wrong.