Commit Graph

1779 Commits

Author SHA1 Message Date
Martyn Inglis
7cfc58c994 Merge branch 'master' into caching-with-redis
Conflicts:
	app/celery/tasks.py
	tests/app/celery/test_tasks.py
2016-11-21 13:10:22 +00:00
Rebecca Law
34d9c44163 Merge pull request #739 from alphagov/refactor-for-reuse-fix
Fix functional tests
2016-11-16 16:24:03 +00:00
Rebecca Law
247668202b Fix functional tests 2016-11-16 16:15:30 +00:00
Leo Hemsted
9da0cc84bd Merge pull request #738 from alphagov/leohemsted-patch-1
typo
2016-11-16 16:11:29 +00:00
Leo Hemsted
a51dfb41d0 typo
paul tried to copy + paste command
2016-11-16 16:11:23 +00:00
Rebecca Law
80f3bfcb2c Merge pull request #733 from alphagov/refactor-for-code-reuse
Refactor for code reuse
2016-11-16 15:17:30 +00:00
Rebecca Law
d6c537cf44 Added job_id and row_number to the exception error message if the task needs to be retried. That way we have a way to tie the exception messages together 2016-11-15 11:44:48 +00:00
Leo Hemsted
61a166193c Merge pull request #737 from alphagov/dont-deactivate-twice
archive service - don't re-delete templates etc
2016-11-14 17:04:52 +00:00
Rebecca Law
2d9d4013e8 Missed one 2016-11-14 15:29:23 +00:00
Rebecca Law
c00eb0f5a4 Remove from_request method on the Notification db model, was not needed anymore.
Use Notifications.query.one(), rather than assert count is 1 and query for all and get first item in list.
2016-11-14 14:41:32 +00:00
Leo Hemsted
d706d86c9c don't re-delete already archived/revoked templates/api-keys 2016-11-14 14:10:40 +00:00
Chris Hill-Scott
e2de83a1b2 Merge pull request #730 from alphagov/letter-templates
Add ‘letter’ as a possible template type
2016-11-14 15:09:28 +01:00
Martyn Inglis
ac6609e653 Couple of bugs squashed.
1) It's incr not inc on the redis client, so renamed the calls everywhere
2) Redis returns bytes/string rather than an int if the value stored is an int. Cast the result to an int before use. Not you can set up the GET to do this transparently but I've not done this as we *may * use GETS for non-int and  the callback sets up the cast for the connection not the call.
2016-11-12 15:37:57 +00:00
Martyn Inglis
4c0c30bb2e Ensure we count the tasks as well as the API calls.
After we have written to the database and placed it on a deliver queue we count it in the cache against the service.

This is the equivalent of doing it at the end of the API call.
2016-11-11 17:36:38 +00:00
Rebecca Law
4379308189 Fix test failures. 2016-11-11 17:28:15 +00:00
Martyn Inglis
033a3e530b Increment the redis cache on a successful API call.
These means that the cache count is on Notifications in the database NOT notifications sent to providers. If the provider fails to accept the notification, it still counts.

I think this is correct, as they have done the work to send it so we should count it, though there is an argument that we should count them on sending?
2016-11-11 17:19:27 +00:00
Chris Hill-Scott
28d5da638b Remove old style fixture
Use new `client` one instead
2016-11-11 17:05:41 +00:00
Rebecca Law
8f0a96c76c Merge branch 'master' into refactor-for-code-reuse 2016-11-11 16:51:18 +00:00
Martyn Inglis
88f04a46cf Implemented the rate limiting from Redis
- Uses Redis cache to check for current count
- If not present then sets the value based on the database state
- Any Redis errors are swallowed. Cache failures should NOT fail  the request.
2016-11-11 16:47:52 +00:00
Chris Hill-Scott
6127ee422a Test can get letter template
It works already, just making sure it stays working.
2016-11-11 16:47:07 +00:00
Chris Hill-Scott
73fe331dc8 Test can create letters template
It works already, just making sure it stays working.
2016-11-11 16:47:06 +00:00
Chris Hill-Scott
f34b58e7cd Delete redundant test
Not needed now that the test above this one is parametrized.
2016-11-11 16:47:06 +00:00
Chris Hill-Scott
aef62dcffb Parametrize template create
Cleaner than having two almost identical tests.
2016-11-11 16:47:06 +00:00
Chris Hill-Scott
705a0e7ab8 Remove redundant assignment
This variable is used exactly once, on the next line 🤔
2016-11-11 16:47:06 +00:00
Chris Hill-Scott
3e6d581f73 Use constants for template type
Handy if we ever want to rename these I guess…
2016-11-11 16:47:05 +00:00
Chris Hill-Scott
eb17822564 Merge pull request #734 from alphagov/fix-conflicting-migration-versions
Fix conflicting migration versions
2016-11-11 17:45:55 +01:00
Chris Hill-Scott
35e1e06db4 Fix conflicting migration versions
Two different versions of 0059 were merged.

`0059_set_services_to_active` was merged first, so this renames my
migration to `0060`, so it goes in afterwards.
2016-11-11 16:30:05 +00:00
Chris Hill-Scott
7ada78a0b6 Merge pull request #731 from alphagov/letter-templates-db
Add letter to possible template types in DB
2016-11-11 17:13:33 +01:00
Rebecca Law
4f5254134b Fix logging in send_sms and send_email 2016-11-11 16:09:09 +00:00
Rebecca Law
4fe8d700ae Fix the send_sms and send_email code to send the notification id that has been persisted. 2016-11-11 16:00:31 +00:00
Leo Hemsted
95764af6ea Merge pull request #723 from alphagov/active-service
deactivate a service
2016-11-11 15:25:32 +00:00
Rebecca Law
c45d1f63a7 Use the same method to persist a notification.
Refactored the send_sms task to use this method.
2016-11-11 14:56:33 +00:00
Leo Hemsted
195f3615e6 add test that if we have an exception, nothing is committed 2016-11-11 14:40:25 +00:00
imdadahad
10f9dfde6e Merge pull request #725 from alphagov/update-user-profile-endpoints
Refactor saving user profile
2016-11-11 11:24:31 +00:00
Leo Hemsted
9ae6e14140 move deactivate functionality into one database transactions
this means that any errors will cause the entire thing to roll back

unfortunately, to do this we have to circumvent our regular code, which calls commit a lot, and lazily loads a lot of things, which will flush, and cause the version decorators to fail. so we have to write a lot of stuff by hand and re-select the service (even though it's already been queried) just to populate the api_keys and templates relationship on it
2016-11-11 11:20:41 +00:00
Rebecca Law
2e4fab1b55 Merge pull request #732 from alphagov/change-v2-error-resp
Change v2 error resp
2016-11-11 11:07:59 +00:00
Rebecca Law
488ba7a1ef Remove import 2016-11-11 10:56:21 +00:00
Rebecca Law
b0d88e0888 Removed OrderedDict
Added missing assert in test
2016-11-11 10:50:38 +00:00
Rebecca Law
eafbbd9809 Refactor send_sms and send_email to use common code to persist the notificaiton. 2016-11-11 10:41:39 +00:00
Chris Hill-Scott
6501a871bc Add letter to possible template types in DB
A letter type was added to the `enum` in the `Template` model at the
same it was added to the `Notification` model. But the migration was
only done for the `notifications` table, not the `templates` table.

See: https://github.com/alphagov/notifications-api/commit/25db1bce#diff-516aab258e161fc65e7564dabd2c625aR19

This commit does the migration to add `letter` as a possible value for
the `template_type` column, which is a bit fiddly because `enum`s.

Before:
```
notification_api=# select enum_range(null::template_type);
 enum_range
-------------
 {sms,email}
(1 row)
```

After upgrade:
```
notification_api=# select enum_range(null::template_type);
     enum_range
--------------------
 {sms,email,letter}
(1 row)
```

After downgrade
```
notification_api=# select enum_range(null::template_type);
 enum_range
-------------
 {sms,email}
(1 row)
```
2016-11-11 10:41:09 +00:00
Chris Hill-Scott
d51c63cb6b Merge pull request #722 from alphagov/whitepace-in-personalisation
Ignore case and whitespace in personalisation keys
2016-11-11 11:33:37 +01:00
Rebecca Law
c758694b98 Change validation error message to a string from a dict. 2016-11-10 16:30:51 +00:00
Rebecca Law
7d763260ce Update format of the errors for DataError and exception 2016-11-10 14:53:39 +00:00
Rebecca Law
26d6a0c1a9 Merge branch 'master' into change-v2-error-resp 2016-11-10 14:21:20 +00:00
Leo Hemsted
17cf582502 Merge branch 'master' into active-service 2016-11-10 13:54:02 +00:00
Leo Hemsted
abecb5ff98 Merge pull request #726 from alphagov/auth-500
update python client to 2.0.0
2016-11-10 13:47:34 +00:00
Leo Hemsted
dd004a6154 Merge pull request #727 from alphagov/exc-handl
remove 500/unplanned exception handlers in test
2016-11-10 13:47:13 +00:00
Martyn Inglis
6c27f8023e Added tests for setting and fetching from redis respecting the enabled flag. 2016-11-10 13:22:38 +00:00
Imdad Ahad
f85ee54707 Refactor stuff + stricter validation for updating only ALLOWED user attrs 2016-11-10 13:09:25 +00:00
Imdad Ahad
8b64aa7e79 Use POST endpoint for updating a user attr 2016-11-10 12:07:29 +00:00