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

Change license field to reflect structuredLicense.url or default to empty string #3

Merged
merged 2 commits into from
Sep 7, 2021
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
54 changes: 45 additions & 9 deletions src/dcat-us/dataset-formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('formatDcatDataset', () => {
const expected = {
'@type': 'dcat:Dataset',
identifier: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
license: 'No license provided. Request permission to use.',
license: null,
landingPage: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
title: 'DCAT_Test',
description: 'Some Description',
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('formatDcatDataset', () => {
const expected = {
'@type': 'dcat:Dataset',
identifier: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
license: 'No license provided. Request permission to use.',
license: null,
landingPage: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
title: 'DCAT_Test',
description: 'Some Description',
Expand Down Expand Up @@ -251,7 +251,7 @@ describe('formatDcatDataset', () => {
const expected = {
'@type': 'dcat:Dataset',
identifier: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
license: 'No license provided. Request permission to use.',
license: null,
landingPage: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
title: 'DCAT_Test',
description: 'Some Description',
Expand Down Expand Up @@ -342,7 +342,7 @@ describe('formatDcatDataset', () => {
const expected = {
'@type': 'dcat:Dataset',
identifier: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
license: 'No license provided. Request permission to use.',
license: null,
landingPage: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
title: 'DCAT_Test',
description: 'Some Description',
Expand Down Expand Up @@ -437,7 +437,7 @@ describe('formatDcatDataset', () => {
const expected = {
'@type': 'dcat:Dataset',
identifier: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
license: 'No license provided. Request permission to use.',
license: null,
landingPage: `${siteUrl}/datasets/00000000000000000000000000000000_0`,
title: 'DCAT_Test',
description: 'Some Description',
Expand Down Expand Up @@ -499,7 +499,43 @@ describe('formatDcatDataset', () => {
expect(actual).toEqual(expected);
});

it('object: license should display structuredLicense text', () => {
it('object: license should display structuredLicense url', () => {
const dataset = {
owner: 'fpgis.CALFIRE',
created: 1570747289000,
modified: 1570747379000,
tags: ['Uno', 'Dos', 'Tres'],
extent: {
coordinates: [
[-123.8832, 35.0024],
[-118.3281, 42.0122],
],
type: 'envelope',
},
name: 'DCAT_Test',
description: 'Some Description',
source: 'Test Source',
id: '00000000000000000000000000000000_0',
type: 'Feature Layer',
url: 'https://services1.arcgis.com/jUJYIo9tSA7EHvfZ/arcgis/rest/services/DCAT_Test/FeatureServer/0',
layer: {
geometryType: 'esriGeometryPolygon',
},
server: {
spatialReference: {
wkid: 3310,
},
},
structuredLicense: { text: 'structuredLicense text', url: 'https://google.com' },
licenseInfo: 'licenseInfo text',
};
const expectedLicense = 'https://google.com';

const actual = JSON.parse(formatDcatDataset(dataset, siteUrl));
expect(actual.license).toEqual(expectedLicense);
});

it('object: license should be empty when structuredLicense.url is unavailable', () => {
const dataset = {
owner: 'fpgis.CALFIRE',
created: 1570747289000,
Expand Down Expand Up @@ -529,13 +565,13 @@ describe('formatDcatDataset', () => {
structuredLicense: { text: 'structuredLicense text' },
licenseInfo: 'licenseInfo text',
};
const expectedLicense = 'structuredLicense text';
const expectedLicense = null;

const actual = JSON.parse(formatDcatDataset(dataset, siteUrl));
expect(actual.license).toEqual(expectedLicense);
});

it('object: license should display licenseInfo text when structuredLicense is unavailable', () => {
it('object: license should display null when structuredLicense is unavailable', () => {
const dataset = {
owner: 'fpgis.CALFIRE',
created: 1570747289000,
Expand Down Expand Up @@ -564,7 +600,7 @@ describe('formatDcatDataset', () => {
},
licenseInfo: 'licenseInfo text',
};
const expectedLicense = 'licenseInfo text';
const expectedLicense = null;

const actual = JSON.parse(formatDcatDataset(dataset, siteUrl));
expect(actual.license).toEqual(expectedLicense);
Expand Down
4 changes: 2 additions & 2 deletions src/dcat-us/dataset-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export function formatDcatDataset (hubDataset: HubDatasetAttributes, siteUrl: st

const template = dcatTemplate(dcatCustomizations);

const { structuredLicense: { text = '' } = {}, licenseInfo } = hubDataset;
const { structuredLicense: { url = null } = {} } = hubDataset;

const defaultDataset = {
'@type': 'dcat:Dataset',
identifier: landingPage,
license: text || licenseInfo || 'No license provided. Request permission to use.',
license: url,
landingPage
};

Expand Down
2 changes: 1 addition & 1 deletion src/dcat-us/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('generating DCAT-US 1.1 feed', () => {

expect(chk1['@type']).toBe('dcat:Dataset');
expect(chk1.identifier).toBe('https://download-test-qa-pre-a-hub.hubqa.arcgis.com/datasets/f4bcc1035b7d46cba95e977f4affb6be_0');
expect(chk1.license).toBe('No license provided. Request permission to use.');
expect(chk1.license).toBe(null);
expect(chk1.landingPage).toBe('https://download-test-qa-pre-a-hub.hubqa.arcgis.com/datasets/f4bcc1035b7d46cba95e977f4affb6be_0');
expect(chk1.title).toBe('Tahoe places of interest');
expect(chk1.description).toBe('Description. Here be Tahoe things. You can do a lot here. Here are some more words. And a few more.<div><br /></div><div>with more words</div><div><br /></div><div>adding a few more to test how long it takes for our jobs to execute.</div><div><br /></div><div>Tom was here!</div>');
Expand Down