Skip to content

Commit d5b9b73

Browse files
committed
fix: some tests
1 parent 152dd19 commit d5b9b73

File tree

4 files changed

+25
-32
lines changed

4 files changed

+25
-32
lines changed

docs/useCases.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,6 @@ _See [use case](../src/datasets/domain/useCases/GetDatasetDownloadCount.ts) impl
862862
The `datasetId` parameter is a number for numeric identifiers.
863863
The `includeMDC` parameter is optional.
864864

865-
Note:
866-
867865
- Setting `includeMDC` to True will ignore the `MDCStartDate` setting and return a total count.
868866
- If MDC isn't enabled, the download count will return a total count, without `MDCStartDate`.
869867
- If MDC is enabled but the `includeMDC` is false, the count will be limited to the time before `MDCStartDate`

src/datasets/infra/repositories/DatasetsRepository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export class DatasetsRepository extends ApiRepository implements IDatasetsReposi
249249
true,
250250
queryParams
251251
)
252-
.then((response) => response.data.downloadCount)
252+
.then((response) => response.data)
253253
.catch((error) => {
254254
throw error
255255
})

test/integration/datasets/DatasetsRepository.test.ts

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,28 @@ describe('DatasetsRepository', () => {
11081108

11091109
await deletePublishedDatasetViaApi(testDatasetIds.persistentId)
11101110
})
1111+
})
1112+
1113+
describe('getDatasetDownloadCount', () => {
1114+
test('should return download count for a dataset', async () => {
1115+
const testDatasetIds = await createDataset.execute(TestConstants.TEST_NEW_DATASET_DTO)
1116+
await publishDatasetViaApi(testDatasetIds.numericId)
1117+
await waitForNoLocks(testDatasetIds.numericId, 10)
1118+
const actual = await sut.getDatasetDownloadCount(testDatasetIds.numericId)
1119+
1120+
expect(actual.downloadCount).toBe(0)
1121+
})
1122+
1123+
test('should return download count including MDC data', async () => {
1124+
const testDatasetIds = await createDataset.execute(TestConstants.TEST_NEW_DATASET_DTO)
1125+
await publishDatasetViaApi(testDatasetIds.numericId)
1126+
await waitForNoLocks(testDatasetIds.numericId, 10)
1127+
1128+
const actual = await sut.getDatasetDownloadCount(testDatasetIds.numericId, true)
1129+
1130+
expect(actual.downloadCount).toBe(0)
1131+
})
1132+
11111133
test('should return error when dataset does not exist', async () => {
11121134
await expect(sut.getDatasetDownloadCount(nonExistentTestDatasetId)).rejects.toBeInstanceOf(
11131135
ReadError
@@ -1121,32 +1143,5 @@ describe('DatasetsRepository', () => {
11211143
expectedError
11221144
)
11231145
})
1124-
1125-
describe('getDatasetDownloadCount', () => {
1126-
test('should return download count for a dataset', async () => {
1127-
const testDatasetIds = await createDataset.execute(TestConstants.TEST_NEW_DATASET_DTO)
1128-
const fileMetadata = {
1129-
description: 'test description',
1130-
directoryLabel: 'directoryLabel',
1131-
categories: ['category1', 'category2']
1132-
}
1133-
await uploadFileViaApi(testDatasetIds.numericId, testTextFile1Name, fileMetadata)
1134-
await publishDatasetViaApi(testDatasetIds.numericId)
1135-
await waitForNoLocks(testDatasetIds.numericId, 10)
1136-
const actual = await sut.getDatasetDownloadCount(testDatasetIds.numericId)
1137-
1138-
expect(actual.downloadCount).toBe(0)
1139-
})
1140-
1141-
test('should return download count including MDC data', async () => {
1142-
const testDatasetIds = await createDataset.execute(TestConstants.TEST_NEW_DATASET_DTO)
1143-
await publishDatasetViaApi(testDatasetIds.numericId)
1144-
await waitForNoLocks(testDatasetIds.numericId, 10)
1145-
1146-
const actual = await sut.getDatasetDownloadCount(testDatasetIds.numericId, true)
1147-
1148-
expect(actual.downloadCount).toBe(0)
1149-
})
1150-
})
11511146
})
11521147
})

test/unit/datasets/DatasetsRepository.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ describe('DatasetsRepository', () => {
10301030

10311031
expect(axios.get).toHaveBeenCalledWith(
10321032
`${TestConstants.TEST_API_URL}/datasets/${testDatasetModel.id}/download/count`,
1033-
TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG
1033+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY
10341034
)
10351035
expect(actual).toStrictEqual(testDatasetDownloadCount)
10361036
})
@@ -1043,7 +1043,7 @@ describe('DatasetsRepository', () => {
10431043

10441044
expect(axios.get).toHaveBeenCalledWith(
10451045
`${TestConstants.TEST_API_URL}/datasets/${testDatasetModel.id}/download/count`,
1046-
TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG
1046+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY
10471047
)
10481048
expect(error).toBeInstanceOf(Error)
10491049
})

0 commit comments

Comments
 (0)