Skip to content

Commit

Permalink
#984: +3 tests for clearNotifications (+3 cached automations, +6 API …
Browse files Browse the repository at this point in the history
…calls)
  • Loading branch information
phjulia committed Aug 27, 2023
1 parent 729eb96 commit f691e6c
Show file tree
Hide file tree
Showing 29 changed files with 975 additions and 56 deletions.
3 changes: 2 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ yargs
.option('clear', {
type: 'string',
group: 'Options for updateNotifications:',
describe: 'remove notification email addresses and/or notes',
describe:
"remove notification email addresses and/or notes. Possible options: 'all', 'errorEmail', 'completionEmail', 'notes'",
})
.option('like', {
type: 'string',
Expand Down
26 changes: 11 additions & 15 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1004,23 +1004,19 @@ class Mcdev {
}
}
case 'updateNotifications': {
{
if (
Object.prototype.hasOwnProperty.call(MetadataTypeInfo[type], methodName)
) {
resultArr.push(...(await MetadataTypeInfo[type][methodName](keyArr)));
if (resultArr.length > 0) {
Util.logger.info(`Retrieving ${type} to have most recent changes`);
const retriever = new Retriever(properties, buObject);
await retriever.retrieve([type], resultArr, null, false);
}
} else {
resultArr.push(
...(await this.#updateNotificationsGeneric(type, keyArr, buObject))
);
if (Object.prototype.hasOwnProperty.call(MetadataTypeInfo[type], methodName)) {
resultArr.push(...(await MetadataTypeInfo[type][methodName](keyArr)));
if (resultArr.length > 0) {
Util.logger.info(`Retrieving ${type} to have most recent changes`);
const retriever = new Retriever(properties, buObject);
await retriever.retrieve([type], resultArr, null, false);
}
break;
} else {
resultArr.push(
...(await this.#updateNotificationsGeneric(type, keyArr, buObject))
);
}
break;
}
default: {
if (Util.OPTIONS.like && Object.keys(Util.OPTIONS.like).length) {
Expand Down
4 changes: 1 addition & 3 deletions lib/metadataTypes/Automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,7 @@ class Automation extends MetadataType {
// should be empty if all OK
throw new Error(result);
} else {
Util.logger.info(
Util.getGrayMsg(` - updated notifications for automation '${key}'`)
);
Util.logger.info(`updated notifications for automation '${key}'`);
return 'OK';
}
} catch (ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "bla bla",
"key": "testExisting_automation_clearNotifications",
"name": "testExisting_automation_clearNotifications",
"key": "testExisting_automation_clearNotificationsAll",
"name": "testExisting_automation_clearNotificationsAll",
"r__folder_Path": "my automations",
"schedule": {
"endDate": "2022-07-30T00:00:00",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"description": "bla bla",
"key": "testExisting_automation_clearNotificationsCompletionEmail",
"name": "testExisting_automation_clearNotificationsCompletionEmail",
"r__folder_Path": "my automations",
"schedule": {
"endDate": "2022-07-30T00:00:00",
"icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
"startDate": "2022-07-30T00:00:00",
"timezoneName": "W. Europe Standard Time"
},
"status": "PausedSchedule",
"steps": [
{
"activities": [
{
"name": "testExisting_dataExtract",
"r__type": "dataExtract"
},
{
"name": "testExisting_emailSend",
"r__type": "emailSend"
},
{
"name": "testExisting_fileTransfer",
"r__type": "fileTransfer"
},
{
"name": "testExisting_importFile",
"r__type": "importFile"
},
{
"name": "testExisting_query",
"r__type": "query"
},
{
"name": "testExisting_script",
"r__type": "script"
}
],
"name": ""
}
],
"type": "scheduled",
"notifications": [
{
"email": ["test@test.com"],
"message": "test",
"type": "Error"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"description": "bla bla",
"key": "testExisting_automation_clearNotificationsErrorEmail",
"name": "testExisting_automation_clearNotificationsErrorEmail",
"r__folder_Path": "my automations",
"schedule": {
"endDate": "2022-07-30T00:00:00",
"icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
"startDate": "2022-07-30T00:00:00",
"timezoneName": "W. Europe Standard Time"
},
"status": "PausedSchedule",
"steps": [
{
"activities": [
{
"name": "testExisting_dataExtract",
"r__type": "dataExtract"
},
{
"name": "testExisting_emailSend",
"r__type": "emailSend"
},
{
"name": "testExisting_fileTransfer",
"r__type": "fileTransfer"
},
{
"name": "testExisting_importFile",
"r__type": "importFile"
},
{
"name": "testExisting_query",
"r__type": "query"
},
{
"name": "testExisting_script",
"r__type": "script"
}
],
"name": ""
}
],
"type": "scheduled",
"notifications": [
{
"email": ["test@test.com"],
"message": "test",
"type": "Complete"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"description": "bla bla",
"key": "testExisting_automation_clearNotificationsNotes",
"name": "testExisting_automation_clearNotificationsNotes",
"r__folder_Path": "my automations",
"schedule": {
"endDate": "2022-07-30T00:00:00",
"icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
"startDate": "2022-07-30T00:00:00",
"timezoneName": "W. Europe Standard Time"
},
"status": "PausedSchedule",
"steps": [
{
"activities": [
{
"name": "testExisting_dataExtract",
"r__type": "dataExtract"
},
{
"name": "testExisting_emailSend",
"r__type": "emailSend"
},
{
"name": "testExisting_fileTransfer",
"r__type": "fileTransfer"
},
{
"name": "testExisting_importFile",
"r__type": "importFile"
},
{
"name": "testExisting_query",
"r__type": "query"
},
{
"name": "testExisting_script",
"r__type": "script"
}
],
"name": ""
}
],
"type": "scheduled",
"notifications": [
{
"email": ["test@test.com"],
"message": "",
"type": "Complete"
},
{
"email": ["test@test.com"],
"message": "",
"type": "Error"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "08afb0e2-b00a-4c88-ad2e-updateNotifications",
"name": "testExisting_automation_clearNotifications",
"id": "08afb0e2-b00a-4c88-ad2e-clear",
"name": "testExisting_automation_clear",
"description": "bla bla",
"key": "testExisting_automation_clearNotifications",
"key": "testExisting_automation_clear",
"typeId": 1,
"type": "scheduled",
"statusId": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"id": "08afb0e2-b00a-4c88-ad2e-clearNotificationsAll",
"name": "testExisting_automation_clearNotificationsAll",
"description": "bla bla",
"key": "testExisting_automation_clearNotificationsAll",
"typeId": 1,
"type": "scheduled",
"statusId": 4,
"status": "PausedSchedule",
"categoryId": 290937,
"schedule": {
"id": "b393aa6c-a4a8-4c0f-a148-9250258a7339",
"typeId": 3,
"startDate": "2022-07-30T00:00:00",
"endDate": "2022-07-30T00:00:00",
"scheduledTime": "0001-01-01T07:00:00",
"rangeTypeId": 0,
"occurrences": 1,
"pattern": "<Pattern><PatternType>0</PatternType><DayInterval>1</DayInterval></Pattern>",
"icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
"timezoneName": "W. Europe Standard Time",
"scheduleStatus": "scheduled",
"timezoneId": 5
},
"steps": [
{
"id": "13fda077-0e82-4936-b936-a36b0997fc44",
"name": "",
"step": 1,
"activities": [
{
"id": "8081a992-a27d-4a43-984a-d60114ea1025",
"name": "testExisting_dataExtract",
"activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7",
"objectTypeId": 73,
"displayOrder": 1
},
{
"id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e",
"name": "testExisting_emailSend",
"activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b",
"objectTypeId": 42,
"displayOrder": 2
},
{
"id": "2c77fc42-85eb-4611-98f9-223d29d89d72",
"name": "testExisting_fileTransfer",
"activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6",
"objectTypeId": 53,
"displayOrder": 3
},
{
"id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7",
"name": "testExisting_importFile",
"activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b",
"objectTypeId": 43,
"displayOrder": 4,
"targetDataExtensions": [
{
"id": "21711373-72c1-ec11-b83b-48df37d1deb7",
"name": "testExisting_dataExtension",
"key": "testExisting_dataExtension",
"description": "bla bla",
"rowCount": 0
}
]
},
{
"id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e",
"name": "testExisting_query_WRONG_NAME",
"activityObjectId": "549f0568-607c-4940-afef-437965094dat",
"objectTypeId": 300,
"displayOrder": 5
},
{
"id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e",
"name": "testExisting_script",
"activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4",
"objectTypeId": 423,
"displayOrder": 6
}
]
}
]
}
Loading

0 comments on commit f691e6c

Please sign in to comment.