Commit Graph

140 Commits

Author SHA1 Message Date
Martyn Inglis
8b9319ac7a Merge branch 'master' into scheduled-delivery-of-jobs
Conflicts:
	app/dao/jobs_dao.py
	tests/app/dao/test_jobs_dao.py
	tests/app/job/test_rest.py
2016-08-25 14:53:00 +01:00
Martyn Inglis
10f499805c Updates to create job to handle scheduling
- If the job JSON contains a scheduling date then the new 'job_status" column is set to "scheduled"
- the date is persisted on the JOB row in the database
- Also the job WILL NOT be placed onto the queue of jobs. This is deferred to a later celery beat task.
2016-08-24 16:00:21 +01:00
Leo Hemsted
00d19f63f0 group results by service using itertools
allows us to nicely reuse the existing format_statistics function
2016-08-24 15:00:51 +01:00
Leo Hemsted
4dd924d438 Merge branch 'master' into version-500 2016-08-10 14:55:07 +01:00
Leo Hemsted
f184bb7996 add test for notification status return value
to ensure we never break compatibility
2016-08-09 17:31:38 +01:00
Leo Hemsted
5b7af00295 re-add content_char_count to public GET /notification endpoints
we shouldn't remove stuff from endpoints or we'll break clients
2016-08-09 17:30:38 +01:00
Leo Hemsted
648b4a17c8 remove xfail flag - the test passes properly now! 🎉 2016-08-09 16:57:18 +01:00
Leo Hemsted
4ba3745159 update schema to use template_history for accurate template details
only in the public notification endpoint so far for fear of breaking
things - in an ideal world i'd remove the template relationship
from models entirely and replace that with actual_template
2016-08-09 16:57:18 +01:00
Leo Hemsted
46c0728b12 add actual_template relationship to notification
also renamed the function to make it apparent that it'll join and grab personalisation
2016-08-09 16:57:18 +01:00
Leo Hemsted
91393bdb0d ensure /notifications rather than service/:id/notifications in tests
for content merging
2016-07-26 15:09:25 +01:00
Leo Hemsted
c81b30dba1 separated schemas once more into "with template" and "with personalisation"
"with personalisation" should only be used by the public notification api
"with template" should be used when we want template name, etc details.

also added an xfail test for correctly constructing notification
personalisation
2016-07-26 14:34:59 +01:00
Leo Hemsted
3df0e8ee2d make tests run consistently
* tests on API endpoints that we do not explicitly sort should
  either sort the results or compare results in an orderless way
  (e.g. converting to a set)
* tests that touch the provider_details should reset values after
  running, since the provider_details table is not torn down and
  re-created between tests (unlike most tables)
2016-07-25 09:47:38 +01:00
Chris Hill-Scott
aa12c88551 Add a test for sending email to provider
We had a test like this for sending sms, but not email. This meant that,
for example, we weren’t checking that the provider was getting passed
the HTML and plain text versions of the email.
2016-07-08 11:16:45 +01:00
Chris Hill-Scott
bb3c55ca6c Make send sms test use a template with a newline 2016-07-08 11:16:45 +01:00
Chris Hill-Scott
a8a556d02a Use PassThrough renderer
Implements and depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/49
2016-07-07 22:48:07 +01:00
Leo Hemsted
96513442fe notifications from test api keys dont send for real - a la research_mode
also added a bunch more tests around api keys to help ensure we're behaving in at least a consistent way
2016-07-05 16:29:53 +01:00
Leo Hemsted
eee98e3e52 move callback tests into separate file
also fix syntax errors
2016-07-05 16:20:03 +01:00
Leo Hemsted
011afa4b16 make tests parametrized for all three key types 2016-07-05 16:20:02 +01:00
Leo Hemsted
2cf1d22748 add filters to GET /notifications endpoints to only return for provided key_type
if api_key used to access endpoint is type team, endpoints only return that type -
will 404 if you provide a different ID. Same applies for normal (normal api keys
cannot see team notifications)
also, for convenience, set sample_notification to supply key_type of KEY_TYPE_NORMAL
by default
2016-07-01 14:35:02 +01:00
Leo Hemsted
2b645f490a move get_all_notifications_for_service and get_all_notifications_for_job
moved from notifications/rest -> service/rest and job/rest respectively
endpoint routes not affected
removed requires_admin decorator - that should be set by nginx config
as opposed to python code
2016-06-30 10:44:21 +01:00
Rebecca Law
8435217808 Fix new test for the default status of a notification 2016-06-27 15:02:53 +01:00
Rebecca Law
48e64abd81 Merge branch 'master' into notification-created-status 2016-06-27 14:59:56 +01:00
Rebecca Law
8a0211b3eb Only send to the provider if the notification has a created status.
If the notification ends up in the retry queue and the delivery app is restarted the notification will get sent twice.
This is because when the app is restarted another message will be in the retry queue as message available which is a
duplicate of the one in the queue that is a  message in flight.

This should complete https://www.pivotaltracker.com/story/show/121844427
2016-06-27 14:47:20 +01:00
Adam Shimali
3423c0c44d Added subject for email templates 2016-06-23 15:21:03 +01:00
Adam Shimali
f65b86cfc9 Body of notification without placeholder should have been present. 2016-06-23 10:25:07 +01:00
Adam Shimali
ed5bdb7be8 Merge pull request #467 from alphagov/notification-created-status
Notification created status for send_sms
2016-06-23 10:21:43 +01:00
Leo Hemsted
c92138d5ab return replaced subject back from get notifications API 2016-06-22 16:24:34 +01:00
Rebecca Law
fcb5ca9ef4 The send_sms task will created the notification with a status = created.
The encrypted_notification for the send_sms_to_provider task has been made optional.
2016-06-22 13:32:27 +01:00
Adam Shimali
731bb19a9c Template and personalisation content is now merged and returned with
notifications, when retrieved by notification id, or service id (i.e.
all notifications for service).

There is a new element returned at top level of notification json called
body, which is the template content merged with personalisation. This
is consistent with api to endpoint to create notification which returns
what was sent as 'body' in json response.

Merging of template with personalisation is done in the
NotificationStatusSchema.

Personalisation data in encrypted before storing in db.
2016-06-20 16:49:17 +01:00
Leo Hemsted
d0eca79417 move all send_notification tests to separate file 2016-06-15 12:27:57 +01:00
Rebecca Law
470bf7281a Merge pull request #420 from alphagov/use-notify-to-send-email-verification-links
Use notify to send email verification links
2016-06-14 17:00:28 +01:00
Rebecca Law
4c34238a88 Fix send_email task requested from notifications endpoint. 2016-06-14 16:53:52 +01:00
Chris Hill-Scott
7f7743b389 Test for filtering a job by notification status
It’s going to be useful to see all the notifications for a job that are
failed/delivered/etc.

The API seems to support this behaviour already, but it doesn’t seem to
be tested.

This commit adds some testsfor the DAO and REST layers.
2016-06-14 14:07:54 +01:00
Rebecca Law
a6ce109c62 Rename first send_email to send_email_v1.
Fix the tests
2016-06-13 16:16:56 +01:00
Rebecca Law
cd2627e5ed Create a new task called send_email_v2 so that I can get rid of the from_address in the signature.
This is done to make sure we do not lose any messages in the queue during deployment.
2016-06-13 15:31:45 +01:00
Rebecca Law
c9f1eb65a7 Build the from address in the task instead of the rest call. 2016-06-13 14:57:59 +01:00
Leo Hemsted
a487931323 python 34 compatibility 2016-06-02 16:49:34 +01:00
Leo Hemsted
54a1adfe8b fix copypasta error with ses test 2016-06-02 16:30:40 +01:00
Leo Hemsted
d41048f4aa statsd counters for callback statuses
also for the 'code' param from firetext
2016-06-02 15:53:04 +01:00
Rebecca Law
25a1b7f31c Firetext does not have a status code for temporary-failure.
In order to set a message as temporary-failure, we check if it is in pending status first.
Otherwise a delivery receipt for failure is set to permanent failure.
2016-05-26 16:46:00 +01:00
Rebecca Law
fa152c4431 Mark a declined message from Firetext as permanent-failure rather than failed. 2016-05-24 15:32:48 +01:00
Leo Hemsted
24625a44f3 prevent public api from sending archived templates 2016-05-24 13:08:38 +01:00
Rebecca Law
cf2723bdc9 If the sms client provider sends more than one delivery receipt only take the update for the the first one.
Only update the notification.status if status = sending.
2016-05-20 17:04:56 +01:00
NIcholas Staples
e0f6b4e571 Merge pull request #327 from alphagov/add_job_row_number
Added job row number to the notification for csv jobs. All tests pass…
2016-05-19 14:33:21 +01:00
Adam Shimali
955005d7fe Added additional outcome status codes to mmg responses. 2016-05-19 11:27:22 +01:00
Nicholas Staples
0fe0c1d2b4 Added job row number to the notification for csv jobs. All tests passing. 2016-05-19 10:46:03 +01:00
Nicholas Staples
c46216dd96 Fix test to check for decrypted dictionary value. 2016-05-18 14:28:19 +01:00
Rebecca Law
281a93b32d Update ses callback to interpret hard and soft bounces.
If the notification has a status == sending then update the status otherwise do not update the status.
In other words do not change the status more than once.
2016-05-17 15:38:49 +01:00
minglis
3c751d94a4 Merge pull request #309 from alphagov/statsd-integration
Statsd integration
2016-05-16 12:29:14 +01:00
Martyn Inglis
a60e11a1b6 Fixed test bug due to pluralisation typo 2016-05-13 17:25:34 +01:00