Skip to content

Commit

Permalink
#984: added 2 test cases for updateNotifications
Browse files Browse the repository at this point in the history
  • Loading branch information
phjulia committed Aug 7, 2023
1 parent 49440b9 commit 10a3fe3
Show file tree
Hide file tree
Showing 9 changed files with 286 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,8 @@ class Mcdev {
Util.logger.error(`No email addresses or run notes were provided`);
return null;
}
return this.#runMethod('updateNotifications', businessUnit, selectedType, keys);
const result = this.#runMethod('updateNotifications', businessUnit, selectedType, keys);
return result;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"description": "bla bla",
"key": "testExisting_automation_updateNotifications",
"name": "testExisting_automation_updateNotifications",
"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": "Error"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"id": "08afb0e2-b00a-4c88-ad2e-updateNotifications",
"name": "testExisting_automation_updateNotifications",
"description": "bla bla",
"key": "testExisting_automation_updateNotifications",
"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
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_updateNotifications",
"workers": [
{
"programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_updateNotifications",
"id": "NGIzZGQ5N2EtMDI0ZS00MzFiLTg5ZWYtNTdjYTI4ODVjMjQ0OjEyOjA",
"notificationType": "Error",
"definition": "test@test.com",
"body": "",
"channelType": "Account"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@
"isPlatformObject": false,
"notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow",
"automationType": "scheduled"
},
{
"id": "RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_updateNotifications",
"key": "testExisting_automation_updateNotifications",
"createdDate": "2022-01-12T08:41:35.773Z",
"name": "testExisting_automation_updateNotifications",
"description": "bla bla",
"clientId": 9999999,
"status": "Building",
"createdBy": {
"id": "NzE3MzUzNDA1OjQ6MA",
"name": "Tom Tester",
"email": "tom.tester@accenture.com"
},
"modifiedDate": "2022-11-11T16:42:36.513Z",
"modifiedBy": {
"id": "NzE3MzUzNDA1OjQ6MA",
"name": "Tom Tester",
"email": "tom.tester@accenture.com"
},
"isPlatformObject": false,
"notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow_updateNotifications",
"automationType": "scheduled"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsa:Action>RetrieveResponse</wsa:Action>
<wsa:MessageID>urn:uuid:60a72d4a-847e-4d9b-a4eb-a42951078298</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:0b59ed53-72ec-4481-ae06-4ee78912aef2</wsa:RelatesTo>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-f95f3fd3-c763-4e2c-929f-33611e9d2eba">
<wsu:Created>2023-06-01T12:04:20Z</wsu:Created>
<wsu:Expires>2023-06-01T12:09:20Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
<soap:Body>
<RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<OverallStatus>OK</OverallStatus>
<RequestID>3b1c8cee-b270-49cb-b77b-e7b33934d1b6</RequestID>
<Results xsi:type="Program">
<PartnerKey xsi:nil="true" />
<ObjectID>08afb0e2-b00a-4c88-ad2e-updateNotifications</ObjectID>
</Results>
</RetrieveResponseMsg>
</soap:Body>
</soap:Envelope>
6 changes: 6 additions & 0 deletions test/resources/9999999/program/retrieve-response.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
<Name>testExisting_automation_pause</Name> <!--only retrieved for cache-->
<CustomerKey>testExisting_automation_pause</CustomerKey> <!--only retrieved for cache-->
</Results>
<Results xsi:type="Program">
<PartnerKey xsi:nil="true" />
<ObjectID>08afb0e2-b00a-4c88-ad2e-updateNotifications</ObjectID>
<Name>testExisting_automation_updateNotifications</Name> <!--only retrieved for cache-->
<CustomerKey>testExisting_automation_updateNotifications</CustomerKey> <!--only retrieved for cache-->
</Results>
</RetrieveResponseMsg>
</soap:Body>
</soap:Envelope>
86 changes: 75 additions & 11 deletions test/type.automation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('type: automation', () => {
const result = cache.getCache();
assert.equal(
result.automation ? Object.keys(result.automation).length : 0,
2,
'only two automations expected'
3,
'only three automations expected'
);
assert.deepEqual(
await testUtils.getActualJson('testExisting_automation', 'automation'),
Expand All @@ -50,7 +50,7 @@ describe('type: automation', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
15,
17,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand All @@ -70,8 +70,8 @@ describe('type: automation', () => {
const result = cache.getCache();
assert.equal(
result.automation ? Object.keys(result.automation).length : 0,
3,
'three automations expected'
4,
'four automations expected'
);
// insert
assert.deepEqual(
Expand Down Expand Up @@ -135,8 +135,8 @@ describe('type: automation', () => {
const cached = cache.getCache();
assert.equal(
cached.automation ? Object.keys(cached.automation).length : 0,
2,
'two cached automation expected'
3,
'three cached automation expected'
);
assert.equal(
deployed['testInstance/testBU'].automation
Expand Down Expand Up @@ -197,8 +197,8 @@ describe('type: automation', () => {
const cached = cache.getCache();
assert.equal(
cached.automation ? Object.keys(cached.automation).length : 0,
2,
'two cached automation expected'
3,
'three cached automation expected'
);
assert.equal(
deployed['testInstance/testBU'].automation
Expand Down Expand Up @@ -294,7 +294,11 @@ describe('type: automation', () => {
});
it('Should create a automation template via buildTemplate and build it', async () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['automation']);
await handler.retrieve(
'testInstance/testBU',
['automation'],
['testExisting_automation']
);
// GIVEN there is a template
const result = await handler.buildTemplate(
'testInstance/testBU',
Expand Down Expand Up @@ -334,7 +338,7 @@ describe('type: automation', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
15,
14,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -571,4 +575,64 @@ describe('type: automation', () => {
return;
});
});
describe('Update notifications ================', () => {
it('Should update run failure email address', async () => {
handler.setOptions({ errorEmail: 'test@test.com' });
const updatedNotifications = await handler.updateNotifications(
'testInstance/testBU',
'automation',
['testExisting_automation_updateNotifications']
);
// need to retrieve first (will be removed once the function updates the automation in retrieve dir)
await handler.retrieve(
'testInstance/testBU',
['automation'],
['testExisting_automation_updateNotifications']
);
assert.equal(
process.exitCode,
false,
'update notifications should not have thrown an error'
);
assert.equal(
updatedNotifications['testInstance/testBU'].length,
1,
'one automation expected'
);
assert.deepEqual(
await testUtils.getActualJson(
'testExisting_automation_updateNotifications',
'automation'
),
await testUtils.getExpectedJson('9999999', 'automation', 'updateNotifications'),
'returned metadata was not equal expected for update'
);
return;
});
it('Should NOT update run completion note', async () => {
handler.setOptions({ completionNote: 'test' });
const updatedNotifications = await handler.updateNotifications(
'testInstance/testBU',
'automation',
['testExisting_automation_updateNotifications']
);
// need to retrieve first
await handler.retrieve(
'testInstance/testBU',
['automation'],
['testExisting_automation_updateNotifications']
);
assert.equal(
process.exitCode,
false,
'update notifications should not have thrown an error'
);
assert.equal(
updatedNotifications['testInstance/testBU'].length,
0,
'zero automation keys expected'
);
return;
});
});
});

0 comments on commit 10a3fe3

Please sign in to comment.