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

feat: reset dataset before every api test #1131

Merged
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
3 changes: 3 additions & 0 deletions test/DatasetAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const dataset3 = {
};

describe("0300: DatasetAuthorization: Test access to dataset", () => {
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
3 changes: 3 additions & 0 deletions test/DatasetFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ const RawCorrect4 = {
};

describe("0400: DatasetFilter: Test retrieving datasets using filtering capabilities", () => {
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
3 changes: 3 additions & 0 deletions test/DatasetLifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ var policyIds = null;
const raw2 = { ...TestData.RawCorrect };

describe("0500: DatasetLifecycle: Test facet and filter queries", () => {
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
3 changes: 3 additions & 0 deletions test/DerivedDataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ var minPid = null;
var explicitPid = null;

describe("0700: DerivedDataset: Derived Datasets", () => {
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
3 changes: 3 additions & 0 deletions test/DerivedDatasetDatablock.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ describe("0750: DerivedDatasetDatablock: Test Datablocks and their relation to d
let datablockId2 = null;

beforeEach((done) => {
before(() => {
db.collection("Dataset").deleteMany({});
});
utils.getToken(
appUrl,
{
Expand Down
4 changes: 4 additions & 0 deletions test/DerivedDatasetOrigDatablock.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ describe("0800: DerivedDatasetOrigDatablock: Test OrigDatablocks and their relat
let origDatablockId2 = null;

beforeEach((done) => {
before(() => {
db.collection("Dataset").deleteMany({});
db.collection("OrigDatablock").deleteMany({});
});
utils.getToken(
appUrl,
{
Expand Down
3 changes: 3 additions & 0 deletions test/ElasticSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const scientificMetadata = ({
(isESenabled ? describe : describe.skip)(
"ElastiSearch: CRUD, filtering and search test case",
() => {
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
3 changes: 3 additions & 0 deletions test/Instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ let accessTokenAdminIngestor = null,
const newName = "ESS3-1";

describe("0900: Instrument: instrument management, creation, update, deletion and search", () => {
before(() => {
db.collection("Instrument").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
6 changes: 5 additions & 1 deletion test/InstrumentsFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const InstrumentCorrect4 = {
};

describe("1000: InstrumentFilter: Test retrieving instruments using filtering capabilities", () => {
before(() => {
db.collection("Instrument").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down Expand Up @@ -79,7 +82,8 @@ describe("1000: InstrumentFilter: Test retrieving instruments using filtering ca
appUrl,
{
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
password:
TestData.Accounts["archiveManager"]["password"],
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
Expand Down
3 changes: 3 additions & 0 deletions test/Jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var origDatablockId = null;

describe.skip("1100: Jobs: Test New Job Model", () => {
before((done) => {
db.collection("Dataset").deleteMany({});
db.collection("Job").deleteMany({});

archiveJob = { ...TestData.ArchiveJob };
retrieveJob = { ...TestData.RetrieveJob };
publicJob = { ...TestData.PublicJob };
Expand Down
22 changes: 13 additions & 9 deletions test/OrigDatablockForRawDataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ var accessTokenAdminIngestor = null,
origDatablockWithValidChkAlg = null;

describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relation to raw Datasets using origdatablocks endpoint", () => {
before(() => {
db.collection("Dataset").deleteMany({});
db.collection("OrigDatablock").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down Expand Up @@ -147,7 +151,7 @@ describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relati
it("0050: adds a new origDatablock with wrong account which should fail", async () => {
origDatablockData1.datasetId = datasetPid1;
return request(appUrl)
.post(`/api/v3/OrigDatablocks`)
.post(`/api/v3/origDatablocks`)
.send(origDatablockData1)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenArchiveManager}` })
Expand All @@ -158,7 +162,7 @@ describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relati
it("0060: adds a new origDatablock with correct account (origdatablock 1)", async () => {
origDatablockData1.datasetId = datasetPid1;
return request(appUrl)
.post(`/api/v3/OrigDatablocks`)
.post(`/api/v3/origDatablocks`)
.send(origDatablockData1)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
Expand All @@ -176,7 +180,7 @@ describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relati
it("0070: adds a second origDatablock (origdatablock 2)", async () => {
origDatablockData2.datasetId = datasetPid1;
return request(appUrl)
.post(`/api/v3/OrigDatablocks`)
.post(`/api/v3/origDatablocks`)
.send(origDatablockData2)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
Expand All @@ -193,7 +197,7 @@ describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relati

it("0080: add a new origDatablock with empty chkAlg should fail", async () => {
return request(appUrl)
.post(`/api/v3/OrigDatablocks`)
.post(`/api/v3/origDatablocks`)
.send(origDatablockWithEmptyChkAlg)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
Expand All @@ -207,7 +211,7 @@ describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relati
it("0090: add a new origDatablock with valid chkAlg should success (origdatablock 3)", async () => {
origDatablockData3.datasetId = datasetPid2;
return request(appUrl)
.post(`/api/v3/OrigDatablocks`)
.post(`/api/v3/origDatablocks`)
.send(origDatablockData3)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
Expand All @@ -229,7 +233,7 @@ describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relati
const filter = { where: { datasetId: datasetPid1 } };

return request(appUrl)
.get(`/api/v3/OrigDatablocks`)
.get(`/api/v3/origDatablocks`)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
.query({ filter: JSON.stringify(filter) })
Expand All @@ -246,7 +250,7 @@ describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relati
const filter = { where: { datasetId: datasetPid2 } };

return request(appUrl)
.get(`/api/v3/OrigDatablocks`)
.get(`/api/v3/origDatablocks`)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
.query({ filter: JSON.stringify(filter) })
Expand Down Expand Up @@ -727,7 +731,7 @@ describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relati
const filter = { where: { datasetId: datasetPid1 } };

return request(appUrl)
.get(`/api/v3/OrigDatablocks`)
.get(`/api/v3/origDatablocks`)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
.query({ filter: JSON.stringify(filter) })
Expand All @@ -742,7 +746,7 @@ describe("1200: OrigDatablockForRawDataset: Test OrigDatablocks and their relati
const filter = { where: { datasetId: datasetPid2 } };

return request(appUrl)
.get(`/api/v3/OrigDatablocks`)
.get(`/api/v3/origDatablocks`)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
.query({ filter: JSON.stringify(filter) })
Expand Down
3 changes: 3 additions & 0 deletions test/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var testdataset = {
};

describe("1300: Policy: Simple Policy tests", () => {
before(() => {
db.collection("Policy").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
3 changes: 3 additions & 0 deletions test/Proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ let accessTokenProposalIngestor = null,
attachmentId = null;

describe("1500: Proposal: Simple Proposal", () => {
before(() => {
db.collection("Proposal").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
10 changes: 7 additions & 3 deletions test/ProposalAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const utils = require("./LoginUtils");
const { TestData } = require("./TestData");
const sandbox = require("sinon").createSandbox();

let accessTokenProposalIngestor= null,
let accessTokenProposalIngestor = null,
accessTokenArchiveManager = null,
accessTokenAdminIngestor = null,
accessTokenUser1 = null,
Expand Down Expand Up @@ -40,6 +40,9 @@ const proposal3 = {
};

describe("1400: ProposalAuthorization: Test access to proposal", () => {
before(() => {
db.collection("Proposal").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand All @@ -48,7 +51,7 @@ describe("1400: ProposalAuthorization: Test access to proposal", () => {
password: TestData.Accounts["adminIngestor"]["password"],
},
(tokenVal) => {
accessTokenAdminIngestor= tokenVal;
accessTokenAdminIngestor = tokenVal;

utils.getToken(
appUrl,
Expand Down Expand Up @@ -78,7 +81,8 @@ describe("1400: ProposalAuthorization: Test access to proposal", () => {
appUrl,
{
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
password:
TestData.Accounts["archiveManager"]["password"],
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
Expand Down
4 changes: 4 additions & 0 deletions test/PublishedData.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const nonpublictestdataset = {
};

describe("1600: PublishedData: Test of access to published data", () => {
before(() => {
db.collection("Dataset").deleteMany({});
db.collection("PublishedData").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
6 changes: 5 additions & 1 deletion test/RandomizedDatasetPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ async function removeAllDatasets() {
}

describe("1700: Randomized Datasets: permission test with bigger amount of data", async () => {
before(() => {
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down Expand Up @@ -222,7 +225,8 @@ describe("1700: Randomized Datasets: permission test with bigger amount of data"
appUrl,
{
username: "archiveManager",
password: TestData.Accounts["archiveManager"]["password"],
password:
TestData.Accounts["archiveManager"]["password"],
},
(tokenVal) => {
accessTokenArchiveManager = tokenVal;
Expand Down
4 changes: 4 additions & 0 deletions test/RawDataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ var accessTokenArchiveManager = null;
var proposalId = null;

describe("1900: RawDataset: Raw Datasets", () => {
before(() => {
db.collection("Dataset").deleteMany({});
db.collection("Proposals").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
appUrl,
Expand Down
3 changes: 3 additions & 0 deletions test/RawDatasetDatablock.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ describe("1800: RawDatasetDatablock: Test Datablocks and their relation to raw D
var datablockId2 = null;

beforeEach((done) => {
before(() => {
db.collection("Dataset").deleteMany({});
});
utils.getToken(
appUrl,
{
Expand Down
4 changes: 4 additions & 0 deletions test/RawDatasetOrigDatablock.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ describe("2000: RawDatasetOrigDatablock: Test OrigDatablocks and their relation
origDatablockWithValidChkAlg = null;

beforeEach((done) => {
before(() => {
db.collection("Dataset").deleteMany({});
db.collection("OrigDatablock").deleteMany({});
});
utils.getToken(
appUrl,
{
Expand Down
1 change: 1 addition & 0 deletions test/Sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let accessTokenAdminIngestor = null,
describe("2200: Sample: Simple Sample", () => {
before(() => {
db.collection("Sample").deleteMany({});
db.collection("Dataset").deleteMany({});
});
beforeEach((done) => {
utils.getToken(
Expand Down
Loading