Modernised ZencoderNotificationTest
This commit is contained in:
@@ -5,17 +5,19 @@ from pillar.tests import AbstractPillarTest
|
|||||||
|
|
||||||
|
|
||||||
class ZencoderNotificationTest(AbstractPillarTest):
|
class ZencoderNotificationTest(AbstractPillarTest):
|
||||||
|
def setUp(self, **kwargs):
|
||||||
|
super().setUp(**kwargs)
|
||||||
|
self.enter_app_context()
|
||||||
|
self.secret = self.app.config['ZENCODER_NOTIFICATIONS_SECRET']
|
||||||
|
|
||||||
def test_missing_secret(self):
|
def test_missing_secret(self):
|
||||||
with self.app.test_request_context():
|
self.post('/api/encoding/zencoder/notifications',
|
||||||
resp = self.client.post('/api/encoding/zencoder/notifications')
|
expected_status=401)
|
||||||
self.assertEqual(401, resp.status_code)
|
|
||||||
|
|
||||||
def test_wrong_secret(self):
|
def test_wrong_secret(self):
|
||||||
with self.app.test_request_context():
|
self.post('/api/encoding/zencoder/notifications',
|
||||||
resp = self.client.post('/api/encoding/zencoder/notifications',
|
headers={'X-Zencoder-Notification-Secret': 'koro'},
|
||||||
headers={'X-Zencoder-Notification-Secret': 'koro'})
|
expected_status=401)
|
||||||
self.assertEqual(401, resp.status_code)
|
|
||||||
|
|
||||||
def test_good_secret_existing_file(self):
|
def test_good_secret_existing_file(self):
|
||||||
self.ensure_file_exists(file_overrides={
|
self.ensure_file_exists(file_overrides={
|
||||||
@@ -24,23 +26,20 @@ class ZencoderNotificationTest(AbstractPillarTest):
|
|||||||
'status': 'processing'}
|
'status': 'processing'}
|
||||||
})
|
})
|
||||||
|
|
||||||
with self.app.test_request_context():
|
self.post('/api/encoding/zencoder/notifications',
|
||||||
secret = self.app.config['ZENCODER_NOTIFICATIONS_SECRET']
|
json={'job': {'id': 'koro-007',
|
||||||
resp = self.client.post('/api/encoding/zencoder/notifications',
|
'state': 'done'},
|
||||||
data=json.dumps({'job': {'id': 'koro-007',
|
'outputs': [{
|
||||||
'state': 'done'},
|
'format': 'jpg',
|
||||||
'outputs': [{
|
'height': 1080,
|
||||||
'format': 'jpg',
|
'width': 2048,
|
||||||
'height': 1080,
|
'file_size_in_bytes': 15,
|
||||||
'width': 2048,
|
'md5_checksum': None,
|
||||||
'file_size_in_bytes': 15,
|
}],
|
||||||
'md5_checksum': None,
|
'input': {
|
||||||
}],
|
'duration_in_ms': 5000,
|
||||||
'input': {
|
}},
|
||||||
'duration_in_ms': 5000,
|
headers={'X-Zencoder-Notification-Secret': self.secret},
|
||||||
}}),
|
expected_status=204)
|
||||||
headers={'X-Zencoder-Notification-Secret': secret,
|
|
||||||
'Content-Type': 'application/json'})
|
|
||||||
|
|
||||||
# TODO: check that the file in MongoDB is actually updated properly.
|
# TODO: check that the file in MongoDB is actually updated properly.
|
||||||
self.assertEqual(204, resp.status_code)
|
|
||||||
|
Reference in New Issue
Block a user