Skip to content

Commit

Permalink
Merge pull request #244 from SciCatProject/revert-original-test-file-…
Browse files Browse the repository at this point in the history
…names

rename test files back to original names and use a copy of test data objects instead of the reference
  • Loading branch information
nitrosx authored Dec 13, 2022
2 parents b11d900 + 15266c6 commit 1e052d4
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 105 deletions.
55 changes: 0 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
"eslint-plugin-prettier": "^4.2.1",
"jest": "27.0.6",
"mocha": "^10.0.0",
"nock": "^13.2.9",
"prettier": "^2.7.1",
"sinon": "^15.0.0",
"supertest": "^6.1.3",
Expand Down
File renamed without changes.
24 changes: 16 additions & 8 deletions test/21-DatasetLifecycle.js → test/DatasetLifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("DatasetLifecycle: Test facet and filter queries", () => {

it("adds another new raw dataset", async () => {
// modify owner
let raw2 = TestData.RawCorrect;
let raw2 = { ...TestData.RawCorrect };
raw2.ownerGroup = "p12345";
return request(appUrl)
.post("/api/v3/Datasets")
Expand All @@ -74,11 +74,12 @@ describe("DatasetLifecycle: Test facet and filter queries", () => {
});

it("Should return datasets with complex join query fulfilled", async () => {

return request(appUrl)
.get(
"/api/v3/Datasets/fullquery?fields=" +
encodeURIComponent(JSON.stringify(TestData.DatasetLifecycle_query_1.fields)),
encodeURIComponent(
JSON.stringify(TestData.DatasetLifecycle_query_1.fields),
),
)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenIngestor}` })
Expand All @@ -93,13 +94,16 @@ describe("DatasetLifecycle: Test facet and filter queries", () => {
});

it("Should return no datasets, because number of hits exhausted", async () => {

return request(appUrl)
.get(
"/api/v3/Datasets/fullquery?fields=" +
encodeURIComponent(JSON.stringify(TestData.DatasetLifecycle_query_2.fields)) +
encodeURIComponent(
JSON.stringify(TestData.DatasetLifecycle_query_2.fields),
) +
"&limits=" +
encodeURIComponent(JSON.stringify(TestData.DatasetLifecycle_query_2.limits)),
encodeURIComponent(
JSON.stringify(TestData.DatasetLifecycle_query_2.limits),
),
)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenIngestor}` })
Expand All @@ -114,9 +118,13 @@ describe("DatasetLifecycle: Test facet and filter queries", () => {
return request(appUrl)
.get(
"/api/v3/Datasets/fullfacet?fields=" +
encodeURIComponent(JSON.stringify(TestData.DatasetLifecycle_query_3.fields)) +
encodeURIComponent(
JSON.stringify(TestData.DatasetLifecycle_query_3.fields),
) +
"&facets=" +
encodeURIComponent(JSON.stringify(TestData.DatasetLifecycle_query_3.facets)),
encodeURIComponent(
JSON.stringify(TestData.DatasetLifecycle_query_3.facets),
),
)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenIngestor}` })
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe("DerivedDatasetDatablock: Test Datablocks and their relation to derived
});

it("adds a second datablock", async () => {
let testdata = TestData.DataBlockCorrect;
let testdata = { ...TestData.DataBlockCorrect };
testdata.archiveId = "some-other-id-that-is-different";
return request(appUrl)
.post(`/api/v3/datasets/${datasetPid}/datablocks`)
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions test/22-Jobs.js → test/Jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ var origDatablockId = null;

describe("Jobs: Test New Job Model", () => {
before((done) => {
archiveJob = TestData.ArchiveJob;
retrieveJob = TestData.RetrieveJob;
publicJob = TestData.PublicJob;
done()
archiveJob = { ...TestData.ArchiveJob };
retrieveJob = { ...TestData.RetrieveJob };
publicJob = { ...TestData.PublicJob };
done();
});

beforeEach((done) => {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/02-Proposal.js → test/Proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe("Proposal: Simple Proposal", () => {
});

it("should add a new attachment to this proposal", async () => {
let testAttachment = TestData.AttachmentCorrect;
let testAttachment = { ...TestData.AttachmentCorrect };
testAttachment.proposalId = defaultProposalId;
return request(appUrl)
.post("/api/v3/Proposals/" + proposalId + "/attachments")
Expand Down
33 changes: 2 additions & 31 deletions test/24-PublishedData.js → test/PublishedData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"use strict";

const utils = require("./LoginUtils");
const nock = require("nock");
const { TestData } = require("./TestData");
const sandbox = require("sinon").createSandbox();

Expand All @@ -15,9 +14,9 @@ let accessToken = null,
attachmentId = null,
doi = null;

const publishedData = TestData.PublishedData;
const publishedData = { ...TestData.PublishedData };

const origDataBlock = TestData.OrigDataBlockCorrect1;
const origDataBlock = { ...TestData.OrigDataBlockCorrect1 };

const modifiedPublishedData = {
publisher: "PSI",
Expand Down Expand Up @@ -110,19 +109,6 @@ describe("PublishedData: Test of access to published data", () => {
});
});

/*
it("should register this new published data", async (done) => {
nock("http://127.0.0.1:3000", {
reqheaders: {
Authorization: `Bearer ${accessToken}`,
},
})
.post("/api/v3/PublishedData/" + doi + "/register")
.reply(200);
done();
});
*/

it("should register this new published data", async () => {
return request(appUrl)
.post("/api/v3/PublishedData/" + doi + "/register")
Expand Down Expand Up @@ -162,21 +148,6 @@ describe("PublishedData: Test of access to published data", () => {
// });
// });

/*
it("should resync this new published data", async (done) => {
nock("http://127.0.0.1:3000", {
reqheaders: {
Authorization: `Bearer ${accessToken}`,
},
})
.post("/api/v3/PublishedData/" + doi + "/resync", {
data: modifiedPublishedData,
})
.reply(200);
done();
});
*/

it("should fetch this new published data", async () => {
return request(appUrl)
.get("/api/v3/PublishedData/" + doi)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe("RawDatasetDatablock: Test Datablocks and their relation to raw Dataset
});

it("adds a second datablock for same dataset", async () => {
let testdata = TestData.DataBlockCorrect;
let testdata = { ...TestData.DataBlockCorrect };
testdata.archiveId = "some-other-archive-id-that-is-different";

return request(appUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe("RawDatasetOrigDatablock: Test OrigDatablocks and their relation to raw
},
);

origDatablockData1 = TestData.OrigDataBlockCorrect1;
origDatablockData2 = TestData.OrigDataBlockCorrect2;
origDatablockData1 = { ...TestData.OrigDataBlockCorrect1 };
origDatablockData2 = { ...TestData.OrigDataBlockCorrect2 };
});

it("adds a new raw dataset", async () => {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/03-Sample.js → test/Sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe("Sample: Simple Sample", () => {
});

it("insert dataset using this sample", async () => {
let dataset = TestData.RawCorrect;
let dataset = { ...TestData.RawCorrect };
dataset.sampleId = sampleId;
return request(appUrl)
.post("/api/v3/Datasets")
Expand Down
File renamed without changes.

0 comments on commit 1e052d4

Please sign in to comment.