Skip to content

Commit b77811a

Browse files
committed
Merge remote-tracking branch 'origin/development'
2 parents d547a32 + f04b981 commit b77811a

File tree

1 file changed

+44
-52
lines changed

1 file changed

+44
-52
lines changed

tests/earthengine.test.js

+44-52
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('With earth-engine-driver', () => {
66
const TESTBACKEND = 'http://earthengine.openeo.org/v0.3';
77
const TESTUSERNAME = 'group5';
88
const TESTPASSWORD = 'test123';
9-
const TESTCAPABILITIES = {"version":"0.3.1","endpoints":[{"path":"/","methods":["GET"]},{"path":"/service_types","methods":["GET"]},{"path":"/output_formats","methods":["GET"]},{"path":"/stac","methods":["GET"]},{"path":"/collections","methods":["GET"]},{"path":"/collections/{collection_id}","methods":["GET"]},{"path":"/processes","methods":["GET"]},{"path":"/files/{user_id}","methods":["GET"]},{"path":"/files/{user_id}/{path}","methods":["GET","PUT","DELETE"]},{"path":"/preview","methods":["POST"]},{"path":"/jobs","methods":["POST","GET"]},{"path":"/jobs/{job_id}","methods":["GET","PATCH","DELETE"]},{"path":"/jobs/{job_id}/results","methods":["GET","POST","DELETE"]},{"path":"/temp/{token}/{file}","methods":["GET"]},{"path":"/services","methods":["GET","POST"]},{"path":"/services/{service_id}","methods":["GET","PATCH","DELETE"]},{"path":"/xyz/{service_id}/{z}/{x}/{y}","methods":["GET"]},{"path":"/subscription","methods":["GET"]},{"path":"/credentials/basic","methods":["GET"]},{"path":"/credentials","methods":["POST"]},{"path":"/me","methods":["GET"]},{"path":"/validation","methods":["POST"]},{"path":"/process_graphs","methods":["GET","POST"]},{"path":"/process_graphs/{process_graph_id}","methods":["GET","PATCH","DELETE"]}],"billing":{"currency":"USD","default_plan":"free","plans":[{"name":"free","description":"Earth Engine is free for research, education, and nonprofit use. For commercial applications, Google offers paid commercial licenses. Please contact earthengine-commercial@google.com for details."}]}};
9+
const TESTCAPABILITIES = {"version":"0.3.1","endpoints":[{"path":"/","methods":["GET"]},{"path":"/service_types","methods":["GET"]},{"path":"/output_formats","methods":["GET"]},{"path":"/stac","methods":["GET"]},{"path":"/collections","methods":["GET"]},{"path":"/collections/{collection_id}","methods":["GET"]},{"path":"/processes","methods":["GET"]},{"path":"/files/{user_id}","methods":["GET"]},{"path":"/files/{user_id}/{path}","methods":["GET","PUT","DELETE"]},{"path":"/preview","methods":["POST"]},{"path":"/jobs","methods":["POST","GET"]},{"path":"/jobs/{job_id}","methods":["GET","PATCH","DELETE"]},{"path":"/jobs/{job_id}/results","methods":["GET","POST"]},{"path":"/temp/{token}/{file}","methods":["GET"]},{"path":"/storage/{job_id}/{file}","methods":["GET"]},{"path":"/services","methods":["GET","POST"]},{"path":"/services/{service_id}","methods":["GET","PATCH","DELETE"]},{"path":"/xyz/{service_id}/{z}/{x}/{y}","methods":["GET"]},{"path":"/subscription","methods":["GET"]},{"path":"/credentials/basic","methods":["GET"]},{"path":"/credentials","methods":["POST"]},{"path":"/me","methods":["GET"]},{"path":"/validation","methods":["POST"]},{"path":"/process_graphs","methods":["GET","POST"]},{"path":"/process_graphs/{process_graph_id}","methods":["GET","PATCH","DELETE"]}],"billing":{"currency":"USD","default_plan":"free","plans":[{"name":"free","description":"Earth Engine is free for research, education, and nonprofit use. For commercial applications, Google offers paid commercial licenses. Please contact earthengine-commercial@google.com for details."}]}};
1010
const TESTCOLLECTION = {"name":"USGS/GTOPO30","title":"GTOPO30: Global 30 Arc-Second Elevation","description":"GTOPO30 is a global digital elevation model (DEM) with a horizontal grid spacing of 30 arc seconds (approximately 1 kilometer). The DEM was derived from several raster and vector sources of topographic information. Completed in late 1996, GTOPO30 was developed over a three-year period through a collaborative effort led by the U.S. Geological Survey's Center for Earth Resources Observation and Science (EROS). The following organizations participated by contributing funding or source data: the National Aeronautics and Space Administration (NASA), the United Nations Environment Programme/Global Resource Information Database (UNEP/GRID), the U.S. Agency for International Development (USAID), the Instituto Nacional de Estadistica Geografica e Informatica (INEGI) of Mexico, the Geographical Survey Institute (GSI) of Japan, Manaaki Whenua Landcare Research of New Zealand, and the Scientific Committee on Antarctic Research (SCAR).","license":"proprietary","extent":{"spatial":[-180,-90,180,90],"temporal":["1996-01-01T00:00:00Z","1996-01-01T00:00:00Z"]}};
1111
const TESTPROCESS = {"name":"count_time","description":"Counts the number of images with a valid mask in a time series for all bands of the input dataset.","parameters":{"imagery":{"description":"EO data to process.","required":true,"schema":{"type":"object","format":"eodata"}}},"returns":{"description":"Processed EO data.","schema":{"type":"object","format":"eodata"}}};
1212
const TESTPROCESSGGRAPH = {"process_id":"stretch_colors","imagery":{"process_id":"min_time","imagery":{"process_id":"NDVI","imagery":{"process_id":"filter_bbox","imagery":{"process_id":"filter_daterange","imagery":{"process_id":"get_collection","name":"COPERNICUS/S2"},"extent":["2018-01-01T00:00:00Z","2018-01-31T23:59:59Z"]},"extent":{"west":16.1,"south":47.2,"east":16.6,"north":48.6}},"red":"B4","nir":"B8"}},"min":-1,"max":1};
@@ -109,7 +109,7 @@ describe('With earth-engine-driver', () => {
109109
var caps = await con.capabilities();
110110
expect(caps).not.toBeNull();
111111
expect(Object.getPrototypeOf(caps).constructor.name).toBe('Capabilities');
112-
expect(caps._data).toEqual(TESTCAPABILITIES);
112+
expect(caps.data).toEqual(TESTCAPABILITIES);
113113
expect(caps.version()).toBe('0.3.1');
114114
expect(caps.listFeatures()).toEqual(TESTCAPABILITIES.endpoints);
115115
expect(caps.listPlans()).toEqual(TESTCAPABILITIES.billing.plans);
@@ -396,66 +396,58 @@ describe('With earth-engine-driver', () => {
396396
await expect(job.estimateJob()).rejects.toThrow();
397397
});
398398

399-
// Starting, Stopping, and working with results as implemented here only works as GEE computes on the fly.
400-
// Other back-ends need more time and therefore we would need to wait here until the started job finished.
401-
// Also, stopping jobs may discard results and therefore working with the results may fail.
402-
test('Start job', async () => {
399+
var targetFolder = Math.random().toString(36);
400+
test('Job Results', async (done) => {
401+
// Start job
403402
await expect(job.startJob()).resolves.toBeTruthy();
404403
var jobdetails = await job.describeJob();
405-
expect(jobdetails.status).toBe('finished');
406-
});
404+
expect(jobdetails.status).toBe('queued');
407405

408-
test('List metalink Results', async () => {
409-
var jobdetails = await job.describeJob();
410-
expect(jobdetails.status).toBe('finished');
411-
await expect(job.listResults("metalink")).rejects.toThrow();
412-
});
406+
var interval = setInterval(async () => {
407+
var jobdetails = await job.describeJob();
408+
if (jobdetails.status !== 'finished') {
409+
return; // Wait until finished
410+
}
413411

414-
test('List json Results', async () => {
415-
var jobdetails = await job.describeJob();
416-
expect(jobdetails.status).toBe('finished');
417-
var res = await job.listResults();
418-
expect(res).not.toBeNull();
419-
expect(res).toHaveProperty("costs");
420-
expect(res).toHaveProperty("expires");
421-
expect(res).toHaveProperty("links");
422-
expect(res.links.length).toBeGreaterThan(0);
423-
expect(res.links[0]).toHaveProperty("href");
424-
});
412+
clearInterval(interval);
413+
var jobdetails = await job.describeJob();
414+
expect(jobdetails.status).toBe('finished');
425415

426-
var targetFolder = Math.random().toString(36);
427-
test('Download results', async () => {
428-
var jobdetails = await job.describeJob();
429-
expect(jobdetails.status).toBe('finished');
430-
if (isBrowserEnv) {
431-
// Browser environment
432-
await expect(job.downloadResults()).rejects.toThrow();
433-
}
434-
else {
435-
// Node environment
436-
// Create folder
437-
const fs = require('fs');
438-
expect(fs.existsSync(targetFolder)).toBeFalsy();
439-
fs.mkdirSync(targetFolder);
440-
expect(fs.existsSync(targetFolder)).toBeTruthy();
441-
// Get links to check against
416+
// Get result list
442417
var res = await job.listResults();
443418
expect(res).not.toBeNull();
419+
expect(res).toHaveProperty("costs");
420+
expect(res).toHaveProperty("expires");
444421
expect(res).toHaveProperty("links");
445422
expect(res.links.length).toBeGreaterThan(0);
446-
// Download files
447-
var files = await job.downloadResults(targetFolder);
448-
expect(files.length).toBe(res.links.length);
449-
for(var i in files) {
450-
expect(fs.existsSync(files[i])).toBeTruthy();
451-
}
452-
}
453-
});
423+
expect(res.links[0]).toHaveProperty("href");
454424

455-
test('Stop job', async () => {
456-
await expect(job.stopJob()).resolves.toBeTruthy();
457-
var jobdetails = await job.describeJob();
458-
expect(jobdetails.status).toBe('canceled');
425+
// Download results
426+
if (isBrowserEnv) {
427+
// Browser environment
428+
await expect(job.downloadResults()).rejects.toThrow();
429+
}
430+
else {
431+
// Node environment
432+
// Create folder
433+
const fs = require('fs');
434+
expect(fs.existsSync(targetFolder)).toBeFalsy();
435+
fs.mkdirSync(targetFolder);
436+
expect(fs.existsSync(targetFolder)).toBeTruthy();
437+
// Get links to check against
438+
var res = await job.listResults();
439+
expect(res).not.toBeNull();
440+
expect(res).toHaveProperty("links");
441+
expect(res.links.length).toBeGreaterThan(0);
442+
// Download files
443+
var files = await job.downloadResults(targetFolder);
444+
expect(files.length).toBe(res.links.length);
445+
for(var i in files) {
446+
expect(fs.existsSync(files[i])).toBeTruthy();
447+
}
448+
}
449+
done();
450+
}, 1000);
459451
});
460452

461453
test('Delete job', async () => {

0 commit comments

Comments
 (0)