Skip to content

Commit

Permalink
fixing endpoints to pass all tests in api test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
amyfromandi committed Oct 24, 2024
1 parent 1211853 commit 4c3fe4f
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 35 deletions.
16 changes: 2 additions & 14 deletions api-tests/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,11 @@ import * as path from 'path';


const testFiles = [
'carto_small.ts',
'columns.ts'
'defs.ts',
'defs_columns.ts',
/*'defs_econs.ts',
'defs_environments.ts',
'defs_groups.ts',
'defs_intervals.ts',
'defs_lithologies.ts',
'defs_lithology_attributes.ts',
'defs_measurements.ts',
'defs_minerals.ts',
'defs_plates.ts',
'defs_projects.ts',
'defs_refs.ts',
'defs_sources.ts',
'defs_strat_name_concepts.ts',
'defs_sources.ts'
/*'defs_strat_name_concepts.ts',
'defs_strat_names.ts',
'defs_structures.ts',
'defs_timescales.ts',
Expand Down
4 changes: 2 additions & 2 deletions api-tests/v2Tests/defs_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
done();
});
});
/*

it("should return a sample", function (done) {
request(settings.host)
.get("/defs/groups?sample")
Expand All @@ -25,7 +25,7 @@
done();
});
});
*/

it("should return all column groups", function (done) {
request(settings.host)
.get("/defs/groups?all")
Expand Down
6 changes: 3 additions & 3 deletions api-tests/v2Tests/defs_intervals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ request(settings.host)
});
});

/*

it("should accept an interval_name", function (done) {
request(settings.host)
.get("/intervals?interval_name=Permian")
.get("/defs/intervals?interval_name=Permian")
.expect(validators.aSuccessfulRequest)
.expect(validators.json)
.expect(validators.atLeastOneResult)
Expand All @@ -126,5 +126,5 @@ request(settings.host)
done();
});
});
*/


13 changes: 9 additions & 4 deletions api-tests/v2Tests/defs_measurements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
});

it("should return a sample", function (done) {
this.timeout(5000);
request(settings.host)
.get("/defs/measurements?sample")
.expect(validators.aSuccessfulRequest)
Expand Down Expand Up @@ -42,8 +43,9 @@
done();
});
});
/*

it("should accept a measurement class", function (done) {
this.timeout(5000);
request(settings.host)
.get("/defs/measurements?measurement_class=geochemical")
.expect(validators.aSuccessfulRequest)
Expand All @@ -61,9 +63,10 @@
done();
});
});
*/


it("should accept a measurement type", function (done) {
this.timeout(5000);
request(settings.host)
.get("/defs/measurements?measurement_type=geochronological")
.expect(validators.aSuccessfulRequest)
Expand All @@ -81,8 +84,10 @@
done();
});
});
/*


it("should return all definitions", function (done) {
this.timeout(5000);
request(settings.host)
.get("/defs/measurements?all")
.expect(validators.aSuccessfulRequest)
Expand All @@ -93,7 +98,7 @@
done();
});
});
*/

it("should return CSV", function (done) {
request(settings.host)
.get(
Expand Down
4 changes: 2 additions & 2 deletions api-tests/v2Tests/defs_minerals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
done();
});
});
/*

it("should accept a mineral name", function (done) {
request(settings.host)
.get("/defs/minerals?mineral=abhurite")
Expand All @@ -49,7 +49,7 @@
done();
});
});
*/

it("should accept a mineral type", function (done) {
request(settings.host)
.get("/defs/minerals?minerals?mineral_type=clinopyroxene")
Expand Down
3 changes: 1 addition & 2 deletions api-tests/v2Tests/defs_plates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
done();
});
});
/*

it("should return a sample", function (done) {
request(settings.host)
.get("/defs/plates?sample")
Expand Down Expand Up @@ -49,4 +49,3 @@
done();
});
});
*/
4 changes: 2 additions & 2 deletions api-tests/v2Tests/defs_projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
done();
});
});
/*

it("should return a sample", function (done) {
request(settings.host)
.get("/defs/projects?sample")
Expand All @@ -25,7 +25,7 @@
done();
});
});
*/


it("should return all projects", function (done) {
request(settings.host)
Expand Down
4 changes: 2 additions & 2 deletions api-tests/v2Tests/defs_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
done();
});
});
/*

it("should accept a source_id", function (done) {
request(settings.host)
.get("/defs/sources?source_id=1,2,3")
Expand Down Expand Up @@ -77,7 +77,7 @@
done();
});
});
*/


it("should accept a scale", function (done) {
request(settings.host)
Expand Down
2 changes: 1 addition & 1 deletion v2/definitions/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = function (req, res, next, cb) {
LEFT JOIN macrostrat.cols ON cols.col_group_id = col_groups.id
LEFT JOIN macrostrat.units_sections ON units_sections.col_id = cols.id
${where}
GROUP BY col_groups.id, cols.project_id;`
GROUP BY col_groups.id, cols.project_id `

if ("sample" in req.query) {
sql += " LIMIT 5";
Expand Down
2 changes: 1 addition & 1 deletion v2/definitions/intervals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function (req, res, next, cb) {

if (req.query.interval_name) {
where.push("intervals.interval_name ILIKE :name");
params["name"] = req.query.interval_name;
params["name"] = '%' + req.query.interval_name + '%';
}

if (req.query.name_like) {
Expand Down
4 changes: 2 additions & 2 deletions v2/definitions/minerals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ module.exports = function (req, res, next, cb) {
sql += " WHERE minerals.id = ANY(:mineral_id)";
params["mineral_id"] = larkin.parseMultipleIds(req.query.mineral_id);
} else if (req.query.mineral) {
sql += " WHERE mineral = ANY(:mineral)";
sql += " WHERE mineral ILIKE ANY(:mineral)";
params["mineral"] = larkin.parseMultipleStrings(req.query.mineral);
} else if (req.query.mineral_type) {
sql += " WHERE min_type = ANY(:mineral_type)";
sql += " WHERE min_type ILIKE ANY(:mineral_type)";
params["mineral_type"] = larkin.parseMultipleStrings(req.query.mineral_type);
} else if (req.query.element) {
/*TODO ensure element param works with abbreviations*/
Expand Down

0 comments on commit 4c3fe4f

Please sign in to comment.