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

[FIX][NRPTI-1226] added missing parameter to transformRecord calls in BCOGC integration utils tests #1227

Merged
merged 1 commit into from
May 22, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('AdministrativePenalty', () => {
description: ''
});

const result = administrativePenalty.transformRecord(baseCsvRow);
const result = administrativePenalty.transformRecord(baseCsvRow, actName);

expect(result).toEqual(expectedResult);
});
Expand All @@ -112,7 +112,7 @@ describe('AdministrativePenalty', () => {
description: 'Although a contravention occurred, a penalty was not assessed. See the attached document for additional details.'
});

const result = administrativePenalty.transformRecord(baseCsvRow);
const result = administrativePenalty.transformRecord(baseCsvRow, actName);

expect(result).toEqual(expectedResult);
});
Expand All @@ -126,7 +126,7 @@ describe('AdministrativePenalty', () => {
description: 'No contravention was found to have occurred, and no penalty was assessed. See the attached document for additional details.'
});

const result = administrativePenalty.transformRecord(baseCsvRow);
const result = administrativePenalty.transformRecord(baseCsvRow, actName);

expect(result).toEqual(expectedResult);
});
Expand Down
2 changes: 1 addition & 1 deletion api/src/integrations/bcogc/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class OgcCsvDataSource {
const recordTypeUtils = recordTypeConfig.getUtil(this.auth_payload, csvRow);

// Perform any data transformations necessary to convert the csv row into a NRPTI record
const nrptiRecord = recordTypeUtils.transformRecord(csvRow, this.actName);
const nrptiRecord = recordTypeUtils.transformRecord(csvRow, this.actName || ENERGY_ACT_CODE);

// Check if this record already exists
const existingRecord = await recordTypeUtils.findExistingRecord(nrptiRecord);
Expand Down
5 changes: 3 additions & 2 deletions api/src/integrations/bcogc/datasource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const BCOGC_INSPECTIONS_CSV_ENDPOINT = process.env.BCOGC_INSPECTIONS_CSV_ENDPOIN
const BCOGC_ORDERS_CSV_ENDPOINT = process.env.BCOGC_ORDERS_CSV_ENDPOINT || 'https://www.bc-er.ca/data-reports/compliance-enforcement/reports/enforcement-order';
const BCOGC_PENALTIES_CSV_ENDPOINT = process.env.BCOGC_PENALTIES_CSV_ENDPOINT || 'https://www.bc-er.ca/data-reports/compliance-enforcement/reports/contravention-decision';
const BCOGC_WARNING_CSV_ENDPOINT = process.env.BCOGC_WARNING_CSV_ENDPOINT || 'https://www.bc-er.ca/data-reports/compliance-enforcement/reports/warning-letter';
const ENERGY_ACT_CODE = 'ACT_103' //unique code for Energy related activities that map to updated legislation names in the acts_regulations_mapping collection in the db

describe('OgcCsvDataSource', () => {
describe('constructor', () => {
Expand Down Expand Up @@ -147,7 +148,7 @@ describe('OgcCsvDataSource', () => {

await dataSource.processRecord(csvRow, recordTypeConfig);

expect(recordTypeUtils.transformRecord).toHaveBeenCalledWith(csvRow);
expect(recordTypeUtils.transformRecord).toHaveBeenCalledWith(csvRow, ENERGY_ACT_CODE );
expect(recordTypeUtils.findExistingRecord).toHaveBeenCalledWith({ transformed: true });
expect(recordTypeUtils.createItem).toHaveBeenCalledWith({ transformed: true });
expect(dataSource.status.itemsProcessed).toEqual(1);
Expand Down Expand Up @@ -179,7 +180,7 @@ describe('OgcCsvDataSource', () => {

await dataSource.processRecord(csvRow, recordTypeConfig);

expect(recordTypeUtils.transformRecord).toHaveBeenCalledWith(csvRow);
expect(recordTypeUtils.transformRecord).toHaveBeenCalledWith(csvRow, ENERGY_ACT_CODE);
expect(recordTypeUtils.findExistingRecord).toHaveBeenCalledWith({ transformed: true });
expect(recordTypeUtils.updateRecord).toHaveBeenCalledWith({ transformed: true }, { _id: 123 });
expect(dataSource.status.itemsProcessed).toEqual(1);
Expand Down
6 changes: 3 additions & 3 deletions api/src/integrations/bcogc/inspections-utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('transformRecord', () => {
});

it('returns basic fields if empty csvRow parameter provided', () => {
const result = inspections.transformRecord({});
const result = inspections.transformRecord({}, actName);

expect(result).toEqual({
_schemaName: 'Inspection',
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('transformRecord', () => {
description: 'description123',
'activities inspected': 'activitiesInspection123',
status: 'statusCancelled'
});
}, actName);

expect(result).toEqual({
_schemaName: 'Inspection',
Expand All @@ -65,7 +65,7 @@ describe('transformRecord', () => {
recordName: 'Inspection Number 123456',
legislation: [
{
act: 'Energy Resource Activities Act',
act: actName,
section: '57',
subSection: '4',
legislationDescription: 'Inspection to verify compliance with regulatory requirement'
Expand Down
6 changes: 3 additions & 3 deletions api/src/integrations/bcogc/orders-utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('orders-utils testing', () => {
});

it('returns basic fields if empty csvRow parameter provided', () => {
const result = orders.transformRecord({});
const result = orders.transformRecord({}, actName);

expect(result).toEqual({
_schemaName: 'Order',
Expand Down Expand Up @@ -51,7 +51,7 @@ describe('orders-utils testing', () => {
Proponent: 'Test Proponent',
Filename: 'sample-order.pdf',
'File URL': 'https://www.example.com/sample-order.pdf'
});
}, actName);

expect(result).toEqual({
_schemaName: 'Order',
Expand All @@ -69,7 +69,7 @@ describe('orders-utils testing', () => {
recordName: 'General Order 123',
legislation: [
{
act: 'Energy Resource Activities Act',
act: actName,
section: 49,
legislationDescription: 'General Order'
}
Expand Down
Loading