Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BHBC-2195-2: Client changes and fixes #975

Merged
merged 17 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12,525 changes: 12,511 additions & 14 deletions api/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/src/paths/project/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('create', () => {

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

sinon.stub(ProjectService.prototype, 'createProjectAndUploadToBiohub').resolves(1);
sinon.stub(ProjectService.prototype, 'createProjectAndUploadMetadataToBioHub').resolves(1);

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

Expand All @@ -51,7 +51,7 @@ describe('create', () => {

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

sinon.stub(ProjectService.prototype, 'createProjectAndUploadToBiohub').rejects(new Error('a test error'));
sinon.stub(ProjectService.prototype, 'createProjectAndUploadMetadataToBioHub').rejects(new Error('a test error'));

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

Expand Down
2 changes: 1 addition & 1 deletion api/src/paths/project/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function createProject(): RequestHandler {

const projectService = new ProjectService(connection);

const projectId = await projectService.createProjectAndUploadToBiohub(sanitizedProjectPostData);
const projectId = await projectService.createProjectAndUploadMetadataToBioHub(sanitizedProjectPostData);

await connection.commit();

Expand Down
4 changes: 2 additions & 2 deletions api/src/paths/project/{projectId}/survey/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('survey/create', () => {

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

sinon.stub(SurveyService.prototype, 'createSurveyAndUploadToBiohub').resolves(2);
sinon.stub(SurveyService.prototype, 'createSurveyAndUploadMetadataToBioHub').resolves(2);

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

Expand All @@ -45,7 +45,7 @@ describe('survey/create', () => {

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

sinon.stub(SurveyService.prototype, 'createSurveyAndUploadToBiohub').rejects(new Error('a test error'));
sinon.stub(SurveyService.prototype, 'createSurveyAndUploadMetadataToBioHub').rejects(new Error('a test error'));

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

Expand Down
2 changes: 1 addition & 1 deletion api/src/paths/project/{projectId}/survey/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export function createSurvey(): RequestHandler {

const surveyService = new SurveyService(connection);

const surveyId = await surveyService.createSurveyAndUploadToBiohub(projectId, sanitizedPostSurveyData);
const surveyId = await surveyService.createSurveyAndUploadMetadataToBioHub(projectId, sanitizedPostSurveyData);

await connection.commit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ describe('deleteSurvey', () => {
.stub(file_utils, 'deleteFileFromS3')
.resolves((true as unknown) as S3.DeleteObjectOutput);

const submitDwCAMetadataPackageStub = sinon.stub(PlatformService.prototype, 'submitDwCAMetadataPackage').resolves();
const submitDwCAMetadataPackageStub = sinon
.stub(PlatformService.prototype, 'submitProjectDwCMetadataToBioHub')
.resolves();

let actualResult: any = null;
const sampleRes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ export function deleteSurvey(): RequestHandler {

try {
const platformService = new PlatformService(connection);
await platformService.submitDwCAMetadataPackage(projectId);
await platformService.submitProjectDwCMetadataToBioHub(projectId);
} catch (error) {
// Don't fail the rest of the endpoint if submitting metadata fails
defaultLog.error({ label: 'deleteSurvey->submitDwCAMetadataPackage', message: 'error', error });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('updateSurvey', () => {

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

sinon.stub(SurveyService.prototype, 'updateSurveyAndUploadToBiohub').resolves();
sinon.stub(SurveyService.prototype, 'updateSurveyAndUploadMetadataToBiohub').resolves();

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

Expand Down Expand Up @@ -48,7 +48,7 @@ describe('updateSurvey', () => {

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

sinon.stub(SurveyService.prototype, 'updateSurveyAndUploadToBiohub').rejects(new Error('a test error'));
sinon.stub(SurveyService.prototype, 'updateSurveyAndUploadMetadataToBiohub').rejects(new Error('a test error'));

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export function updateSurvey(): RequestHandler {

const surveyService = new SurveyService(connection);

await surveyService.updateSurveyAndUploadToBiohub(surveyId, sanitizedPutSurveyData);
await surveyService.updateSurveyAndUploadMetadataToBiohub(surveyId, sanitizedPutSurveyData);

await connection.commit();

Expand Down
76 changes: 0 additions & 76 deletions api/src/paths/project/{projectId}/survey/{surveyId}/upload.test.ts

This file was deleted.

94 changes: 0 additions & 94 deletions api/src/paths/project/{projectId}/survey/{surveyId}/upload.ts

This file was deleted.

2 changes: 1 addition & 1 deletion api/src/paths/project/{projectId}/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe('update', () => {

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

sinon.stub(ProjectService.prototype, 'updateProjectAndUploadToBiohub').resolves();
sinon.stub(ProjectService.prototype, 'updateProjectAndUploadMetadataToBioHub').resolves();

const requestHandler = update.updateProject();

Expand Down
2 changes: 1 addition & 1 deletion api/src/paths/project/{projectId}/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ export function updateProject(): RequestHandler {

const projectService = new ProjectService(connection);

await projectService.updateProjectAndUploadToBiohub(projectId, entities);
await projectService.updateProjectAndUploadMetadataToBioHub(projectId, entities);

await connection.commit();

Expand Down
4 changes: 2 additions & 2 deletions api/src/paths/publish/survey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('survey', () => {

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

sinon.stub(PlatformService.prototype, 'submitSurveyDataPackage').resolves({ uuid: 'test-uuid' });
sinon.stub(PlatformService.prototype, 'submitSurveyDataToBioHub').resolves({ uuid: 'test-uuid' });

const sampleReq = {
keycloak_token: {},
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('survey', () => {

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

sinon.stub(PlatformService.prototype, 'submitSurveyDataPackage').rejects(new Error('a test error'));
sinon.stub(PlatformService.prototype, 'submitSurveyDataToBioHub').rejects(new Error('a test error'));

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

Expand Down
4 changes: 2 additions & 2 deletions api/src/paths/publish/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ export function publishSurvey(): RequestHandler {
return async (req, res) => {
const connection = getDBConnection(req['keycloak_token']);

const { projectId, surveyId, data } = req.body;
const { surveyId, data } = req.body;

try {
await connection.open();

const platformService = new PlatformService(connection);
const response = await platformService.submitSurveyDataPackage(projectId, surveyId, data);
const response = await platformService.submitSurveyDataToBioHub(surveyId, data);

await connection.commit();

Expand Down
Loading