Fix tests

This commit is contained in:
Jake Barnby
2024-02-27 00:27:35 +13:00
parent 2743e6cdbd
commit 7945f1398f
2 changed files with 14 additions and 45 deletions
+5 -5
View File
@@ -2597,7 +2597,7 @@ App::post('/v1/messaging/messages/email')
->param('cc', [], new ArrayList(new UID()), 'Array of target IDs to be added as CC.', true)
->param('bcc', [], new ArrayList(new UID()), 'Array of target IDs to be added as BCC.', true)
->param('attachments', [], new ArrayList(new CompoundUID()), 'Array of compound bucket IDs to file IDs to be attached to the email.', true)
->param('draft', true, new Boolean(), 'Is message a draft', true)
->param('draft', false, new Boolean(), 'Is message a draft', true)
->param('html', false, new Boolean(), 'Is content of type HTML', true)
->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true)
->inject('queueForEvents')
@@ -2745,7 +2745,7 @@ App::post('/v1/messaging/messages/sms')
->param('topics', [], new ArrayList(new UID()), 'List of Topic IDs.', true)
->param('users', [], new ArrayList(new UID()), 'List of User IDs.', true)
->param('targets', [], new ArrayList(new UID()), 'List of Targets IDs.', true)
->param('draft', true, new Boolean(), 'Is message a draft', true)
->param('draft', false, new Boolean(), 'Is message a draft', true)
->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true)
->inject('queueForEvents')
->inject('dbForProject')
@@ -2870,7 +2870,7 @@ App::post('/v1/messaging/messages/push')
->param('color', '', new Text(256), 'Color for push notification. Available only for Android Platform.', true)
->param('tag', '', new Text(256), 'Tag for push notification. Available only for Android Platform.', true)
->param('badge', '', new Text(256), 'Badge for push notification. Available only for IOS Platform.', true)
->param('draft', true, new Boolean(), 'Is message a draft', true)
->param('draft', false, new Boolean(), 'Is message a draft', true)
->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true)
->inject('queueForEvents')
->inject('dbForProject')
@@ -3431,7 +3431,7 @@ App::patch('/v1/messaging/messages/sms/:messageId')
->param('users', null, new ArrayList(new UID()), 'List of User IDs.', true)
->param('targets', null, new ArrayList(new UID()), 'List of Targets IDs.', true)
->param('content', null, new Text(64230), 'Email Content.', true)
->param('draft', true, new Boolean(), 'Is message a draft', true)
->param('draft', null, new Boolean(), 'Is message a draft', true)
->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true)
->inject('queueForEvents')
->inject('dbForProject')
@@ -3595,7 +3595,7 @@ App::patch('/v1/messaging/messages/push/:messageId')
->param('color', null, new Text(256), 'Color for push notification. Available only for Android platforms.', true)
->param('tag', null, new Text(256), 'Tag for push notification. Available only for Android platforms.', true)
->param('badge', null, new Integer(), 'Badge for push notification. Available only for iOS platforms.', true)
->param('draft', true, new Boolean(), 'Is message a draft', true)
->param('draft', null, new Boolean(), 'Is message a draft', true)
->param('scheduledAt', null, new DatetimeValidator(requireDateInFuture: true), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true)
->inject('queueForEvents')
->inject('dbForProject')
+9 -40
View File
@@ -903,7 +903,6 @@ trait MessagingBase
'targets' => [$targetId],
'subject' => 'New blog post',
'content' => 'Check out the new blog post at http://localhost',
'status' => MessageStatus::SCHEDULED,
'scheduledAt' => DateTime::addSeconds(new \DateTime(), 3),
]);
@@ -920,23 +919,6 @@ trait MessagingBase
$this->assertEquals(200, $message['headers']['status-code']);
$this->assertEquals(MessageStatus::FAILED, $message['body']['status']);
/**
* Test for FAILURE
*/
$message = $this->client->call(Client::METHOD_POST, '/messaging/messages/email', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'messageId' => ID::unique(),
'targets' => [$targetId],
'subject' => 'New blog post',
'content' => 'Check out the new blog post at http://localhost',
'status' => MessageStatus::SCHEDULED,
]);
$this->assertEquals(400, $message['headers']['status-code']);
}
public function testScheduledToDraftMessage(): void
@@ -965,7 +947,6 @@ trait MessagingBase
'targets' => [$targetId],
'subject' => 'New blog post',
'content' => 'Check out the new blog post at http://localhost',
'status' => MessageStatus::SCHEDULED,
'scheduledAt' => DateTime::addSeconds(new \DateTime(), 5),
]);
@@ -977,7 +958,7 @@ trait MessagingBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'status' => MessageStatus::DRAFT,
'draft' => true,
]);
$this->assertEquals(200, $message['headers']['status-code']);
@@ -1021,28 +1002,18 @@ trait MessagingBase
'targets' => [$targetId],
'subject' => 'New blog post',
'content' => 'Check out the new blog post at http://localhost',
'status' => MessageStatus::DRAFT,
'draft' => true,
]);
$this->assertEquals(201, $message['headers']['status-code']);
$this->assertEquals(MessageStatus::DRAFT, $message['body']['status']);
$response = $this->client->call(Client::METHOD_PATCH, '/messaging/messages/email/' . $message['body']['$id'], [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'status' => MessageStatus::SCHEDULED,
]);
$this->assertEquals(400, $response['headers']['status-code']);
$message = $this->client->call(Client::METHOD_PATCH, '/messaging/messages/email/' . $message['body']['$id'], [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'status' => MessageStatus::SCHEDULED,
'draft' => false,
'scheduledAt' => DateTime::addSeconds(new \DateTime(), 3),
]);
@@ -1087,7 +1058,6 @@ trait MessagingBase
'targets' => [$targetId],
'subject' => 'New blog post',
'content' => 'Check out the new blog post at http://localhost',
'status' => MessageStatus::SCHEDULED,
'scheduledAt' => DateTime::addSeconds(new \DateTime(), 3),
]);
@@ -1257,7 +1227,7 @@ trait MessagingBase
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'messageId' => ID::unique(),
'status' => 'draft',
'draft' => true,
'topics' => [$email['body']['topics'][0]],
'subject' => 'Khali beats Undertaker',
'content' => 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
@@ -1270,7 +1240,7 @@ trait MessagingBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'status' => 'processing',
'draft' => false,
]);
$this->assertEquals(200, $email['headers']['status-code']);
@@ -1422,7 +1392,7 @@ trait MessagingBase
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'messageId' => ID::unique(),
'status' => 'draft',
'draft' => true,
'topics' => [$sms['body']['topics'][0]],
'content' => 'Your OTP code is 123456',
]);
@@ -1434,7 +1404,7 @@ trait MessagingBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'status' => 'processing',
'draft' => false,
]);
$this->assertEquals(200, $sms['headers']['status-code']);
@@ -1583,7 +1553,7 @@ trait MessagingBase
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'messageId' => ID::unique(),
'status' => 'draft',
'draft' => true,
'topics' => [$push['body']['topics'][0]],
'title' => 'Test-Notification',
'body' => 'Test-Notification-Body',
@@ -1596,7 +1566,7 @@ trait MessagingBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'status' => 'processing',
'draft' => false,
]);
$this->assertEquals(200, $push['headers']['status-code']);
@@ -1640,7 +1610,6 @@ trait MessagingBase
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'messageId' => ID::unique(),
'status' => 'processing',
'topics' => [$topic['$id']],
'subject' => 'Test subject',
'content' => 'Test content',