Commit Graph

17 Commits

Author SHA1 Message Date
Ken Tsang
c4e1d56492 Update letter utils to handle precompiled letters sent by test API keys
- precompiled letters sent using a test key should be put into a test-letters bucket
- also refactored code from test_letter_pdf_tasks
2018-03-14 18:15:00 +00:00
Richard Chapman
42c1040604 Updated API to get it working with Admin.
* Added missing items from template which are required
* Returned the file as a JSON string with the file as a base64 encoded
string
* Updated tests to match teh desired format
2018-03-01 15:01:46 +00:00
Ken Tsang
b6401e4858 Fix boto mocks in tests
- was getting KeyError: 'Error' test failures due to the side_effect not generating enough information to be used in the ClientError class, this PR adds missing information.
2018-02-28 10:54:52 +00:00
Alexey Bezhan
8971a5adce Upload pre-compiled letter PDF to S3
Pre-compiled letter endpoint uploads PDF contents to S3 directly
instead of creating a letter task to generate PDF using template
preview.

This moves some of the utility functions used by existing letter
celery tasks to app.letters.utils, so that they can be reused by
the API endpoint.
2018-02-23 17:52:25 +00:00
Richard Chapman
da669e46f0 Import of time was not needed - removed 2018-02-12 17:08:10 +00:00
Richard Chapman
d2f4f544c1 Added a freezetime to the test test_create_letters_pdf_calls_s3upload
as it failed on prodction and I managed to get it to fail locally

{'file_location': '2018-02-12/NOTIFY.FOO.D.2.C.N.20180212164427.PDF'}
!= {'file_location': '2018-02-12/NOTIFY.FOO.D.2.C.N.20180212164428.PDF'}

A freeze time till ensure that the finame which is based on the time
will not fail.
2018-02-12 16:55:15 +00:00
Leo Hemsted
093e8083e0 upload letter pdfs with retention tag
so we can delete them automatically with s3's lifecycle policy
2018-02-09 17:13:37 +00:00
Ken Tsang
edd030e5dd Refactor code to move business logic
- DVLA specific logic is now moved to letters_pdf_tasks
2018-01-26 14:45:36 +00:00
Leo Hemsted
218fc5e14d only send letters in created state to ftp app for zipping
this means if we end up with some notifications sending and others not,
due to problems with the ftp connectivity for example, we don't re-send
those that worked.

As a reminder, letter pdf notifications start as created and stay that
way until we have sent the zip file to DVLA, at which point they are
updated to sending
 #
2018-01-15 17:00:00 +00:00
Katie Smith
440012288d Add test for max file size and file count when grouping letters 2018-01-03 11:31:22 +00:00
Katie Smith
644b110a8d Group letters into a max number of files for sending to DVLA
Grouping the letters into a maximum number of files is necessary because
the SQS task needs to be under a certain size. We also compress the task
when sending.
2018-01-03 11:31:22 +00:00
Leo Hemsted
9debc96c8c exclude non-pdfs from collate task
and fix celery kwargsg
2018-01-02 10:39:21 +00:00
Leo Hemsted
309b4d7d33 add collate-letter-pdfs task
add collate-letter-pdfs task (name pending). This retrieves a list of
letter pdf files (just the metadata, not the actual data) from s3, and
loops through them, calling the ftp task zip-and-send-letter-pdfs. It
groups them up by adding them to lists while counting the total
filesize, if it gets over a certain filesize (currently set to 500mb)
it breaks at that chunk, sends off that list of files to the ftp app,
and then starts building up a new list.

DVLA have a hard 2gb limit on how big the zip files we can send is -
however we're going to be limited by the amount of memory on the ftp
app well before we get around to handling 2gb of pdf data - so the
limit is 500mb for now. We'll adjust it after we see how ftp performs.
2018-01-02 10:39:21 +00:00
Ken Tsang
0045cd6b72 Use dao_update_notification to update billable_units for letter notifications 2017-12-14 15:09:25 +00:00
Ken Tsang
f23074596b Update billable units for letters pdf task 2017-12-14 15:09:25 +00:00
Ken Tsang
02b67c95e5 Use crown flag from service 2017-12-12 12:07:55 +00:00
Ken Tsang
3464336aff Refactored tasks.py to split out letters_pdf tasks
- Added has_permission helper in models.py to check permission in service
- Moved letters pdf tasks to separate file
- Moved letters pdf tests to own file
2017-12-12 12:07:55 +00:00