Commit Graph

1988 Commits

Author SHA1 Message Date
Rebecca Law
f66670c558 - Added logging to indicate that we created the notification and that we sent the notification to a delivery queue.
- Small updates as recommended by review comments.
2017-01-18 09:56:26 +00:00
Rebecca Law
41b49eb8e0 Make the update template endpoint work when process_type is present. 2017-01-17 15:48:51 +00:00
Rebecca Law
e360a1f8f6 Merge branch 'master' into priority-by-template 2017-01-17 14:08:36 +00:00
Rebecca Law
b34c5f0bcd If the template.process_type = PRIROITY send the message to the notify queue.
We are using the notify queue in this iteration because that queue is a low volume queue with it's own dedicated workers. This just saves us from building a new queue at this point, and a new queue may not be necessary.
2017-01-17 13:16:26 +00:00
Rebecca Law
a8cdabcecd - Refactor v2 post_notification to use a single method for sms and email.
- Added the `simulate` notification logic to version 2. We have 3 email addresses and phone numbers that are used
to simulate a successful post to /notifications. This was missed out of the version 2 endpoint.
- Added a test to template_dao to check for the default value of normal for new templates
- in v2 get_notifications, casted the path param to a uuid, if not uuid abort(404)
2017-01-17 12:08:24 +00:00
Andras Ferencz-Szabo
e10c5e28cd Merge pull request #763 from alphagov/cloudfoundry
Run on Paas
2017-01-17 11:28:38 +00:00
Andras Ferencz-Szabo
3a9f201110 Merge pull request #792 from alphagov/codedeploy_autoscaling
Add Makefile commands to control autoscaling processes
2017-01-16 17:54:13 +00:00
bandesz
e9a90b46b0 Add Makefile commands to control autoscaling processes 2017-01-16 17:53:11 +00:00
Rebecca Law
31de10ae6f dB script to default templates/templates_history.process_type = 'normal' and set the column to not null 2017-01-16 11:19:46 +00:00
Rebecca Law
701851118e Update templates.process_type to be normal and set the column as not null. 2017-01-16 11:15:48 +00:00
Rebecca Law
56f1ed11d6 Merge pull request #791 from alphagov/add-templates-process_type
Add templates process type
2017-01-13 14:53:51 +00:00
Rebecca Law
61b6b1bab9 Merge branch 'master' into add-templates-process_type 2017-01-13 12:30:31 +00:00
Rebecca Law
ceb139ca28 Fix foreign key names 2017-01-13 12:29:13 +00:00
Rebecca Law
6c79ddbe41 This is the first deploy in series of deploys to give certain templates priority in processing.
If the template is marked as priority the notification will be sent using the `notify` queue.
The `notify` queue is a low volume queue, messages here will not be queue behind a large job and should be delivered with in a more consistent time frame.

- Added templates.process_type and templates_history.process_type column.
- Added a template_process_type table to handle the enum for templates.process_type, initial values are normal and priority

https://www.pivotaltracker.com/story/show/135429147
2017-01-13 12:14:34 +00:00
Leo Hemsted
48424b32aa Merge pull request #782 from alphagov/conftest-cleanups
Conftest cleanups
2017-01-13 11:57:55 +00:00
bandesz
ac0e1f1def Add gosu and host user to Docker 2017-01-13 10:24:13 +00:00
bandesz
8300cb0ac0 Add Jenkinsfile 2017-01-13 10:24:13 +00:00
bandesz
c9f3005392 Add quotes around Docker volume definitions 2017-01-13 10:24:13 +00:00
bandesz
fd66fbd719 Run API on Paas 2017-01-13 10:24:13 +00:00
Leo Hemsted
0f327a0995 remove pytest.mark.usefixtures decorator
while it's nice to use the decorator to signify fixtures with side
effects, it has unfortunate problems of completely overriding any
fixtures you've declared in the funcargs - so isn't really suitable
for our usecase where we often have other fixtures we rely on to
return values to us.

So for consistency, let's remove this and stick to using funcargs
to define our fixtures
2017-01-10 15:04:28 +00:00
Leo Hemsted
44a8526807 use pytest.mark.usefixtures instead of funcargs
when you invoke the fixture `sample_user`, it does two things: it
creates the user in the database, but also returns the user, a useful
object that you may want to manipulate or reference in your test.

however, when you invoke the fixture `notify_db_session`, it doesn't
do anything - rather, it *promises* to clear up the database tables
at the end of the test run.

because we have no need of the notify_db_session object in our tests
(indeed, for a long time this fixture just returned `None`), using
`pytest.mark.usefixtures('notify_db_session')` brings attention to the
fact that this is a side-effect fixture rather than a data setup
fixture. Functionally it is identical to passing as a parameter
2017-01-10 15:04:28 +00:00
Leo Hemsted
996bd2579a fix failing tests
make sure we're using notify_db_session to ensure test independence
2017-01-10 15:04:28 +00:00
Leo Hemsted
d550893377 update tests to use create_user instead of sample_user
note that all of these tests have to be checked to ensure that they
still call through to notify_db_session (notify_db not required) to
tear down the database after the test runs - since it's no longer
required to pass it in to the function just to invoke the sample_user
function
2017-01-10 15:04:28 +00:00
Leo Hemsted
aeb79a0de9 refactor sample_user to create a new create_user function
this create_user function can be imported for use in creating specific
users in your tests, for example

```
from tests.app.db import create_user
def test_create_user_persists_to_database(notify_db_session):
    user = create_user()
    assert User.query.count() == 1
```

this has the benefit of not requiring you to pass the notify_db and
notify_db_session fixtures around, and separating custom object
creation from the fixture dependency trees to aid clarity

I started with sample_user since it has no downstream dependencies, but
the intention is to push this out to all db fixtures eventually. This
is a total conversion, but can be rolled out in a non-breaking manner
by keeping arguments in the fixture, and passing them through to the
new db function - then tests can be updated to use the create_* instead
of sample_* functions as and when you want to
2017-01-10 15:04:28 +00:00
Rebecca Law
d759842adc Merge pull request #788 from alphagov/fix-billable-units-query
Fix performance of billable units query
2017-01-10 14:35:07 +00:00
Rebecca Law
cefa00b3fa Merge branch 'master' into fix-billable-units-query
Conflicts:
	tests/app/dao/test_notification_dao.py
2017-01-10 14:24:08 +00:00
Martyn Inglis
46d1e3bdb6 Two new methods needed to pass the service not the service ID into the create notifications methods. 2017-01-10 13:41:16 +00:00
minglis
0c6193e2e9 Merge pull request #775 from alphagov/do-not-write-test-data-to-the-history-table
Do not write test data to the history table
2017-01-10 13:05:06 +00:00
Rebecca Law
ffa54821d9 The previous commit was failing the test in the docker container.
My local version of postgres is 9.6 and docker is using 9.5 (so I am ahead).
However, we found a more simple solution that works for both versions.
2017-01-10 11:21:33 +00:00
Rebecca Law
34a9b8aba4 Merge branch 'master' into fix-billable-units-query 2017-01-10 08:55:23 +00:00
Leo Hemsted
ea1afbe44f Merge pull request #789 from alphagov/utils-bump
bump utils to 13.0.1
2017-01-09 16:55:25 +00:00
Leo Hemsted
501187a9f4 bump utils to 13.0.1
brings in a fix to InvalidEmail/Phone/AddressExceptions not being
instantiated correctly. `exception.message` is not a python standard,
so we shouldn't be relying on it to transmit exception reasons -
rather we should be using `str(exception)` instead. This involved a
handful of small changes to the schema validation
2017-01-09 16:37:58 +00:00
Rebecca Law
a1d8ca9364 Use a variable for the massive month date conversion.
Document the massive date function.
Document the get_april_fools function.
2017-01-09 15:34:24 +00:00
Rebecca Law
88e1e58f24 Fix the get_april_fools method to use March 31 23:00 as the timestamp.
The financial year start April 1, 00:00 BST and our dates are stored as UTC.
Added a test for get_april_fools.
Added some test more test data for get_billable_unit_count_per_month.
2017-01-09 14:54:25 +00:00
Rebecca Law
17767dfa62 Calculating the billing units per month was taking too long for a services with a lot of data.
The query now does the sum per month.
2017-01-09 11:13:24 +00:00
Rebecca Law
098567c151 Merge pull request #785 from alphagov/check-notification_schema
Removed the oneOf validation in the get_notification_response schema.
2017-01-04 13:14:51 +00:00
Rebecca Law
bbdbb9079e Fixed the template uri for the post notification responses.
It was optimistic to think the v2 templates would be complete.
2017-01-04 11:22:50 +00:00
Rebecca Law
7f9111fd90 Removed the oneOf validation in the get_notification_response schema. 2017-01-04 11:00:47 +00:00
Rebecca Law
c8b11ffc8a Merge pull request #783 from alphagov/add-date-filter-to-get-services
Added a date range filter for the get all services end point.
2017-01-03 10:29:23 +00:00
Rebecca Law
0ec84ff5e8 Refactor the get_detailed_services so that the start and end date are not defaulted to None.
Set the start and end date to today's date if they are not set in the request.args
2016-12-29 13:50:41 +00:00
Rebecca Law
1de022f005 Update the query to execute immediately.
Fix indent.
Left a comment as to why start and end date are not set.
2016-12-29 13:28:55 +00:00
Leo Hemsted
8596cc500f Merge pull request #784 from alphagov/cloudfront-fix
don't use cloudfront on preview or staging
2016-12-29 12:23:52 +00:00
Leo Hemsted
d4f23f1e44 don't use cloudfront on preview or staging
cloudfront caching isn't set up on those environments yet, so continue
to use flask for now - in the future we'll want to revert this once
those environments are up and running properly
2016-12-29 12:15:47 +00:00
Leo Hemsted
9e27574298 Merge pull request #779 from alphagov/switch-to-cloudfront
use cloudfront instead of flask to serve static images
2016-12-29 11:35:05 +00:00
Rebecca Law
8ad078b663 Added a date range filter for the get all services end point.
When the start_date and end_date query argruments exists in the request,
the query will return the results from the NotificationHistory table for the given date range.
We will need to check the performance of this query, but this will only be used by the platform admin page.
2016-12-28 15:39:55 +00:00
Leo Hemsted
8c5c712f2b Merge pull request #781 from alphagov/subject-placeholder
fix placeholders not appearing in email subject
2016-12-22 15:35:44 +00:00
Rebecca Law
b2c293e53f Merge pull request #778 from alphagov/refactor-notify-user-endpoints
Refactor notify user endpoints
2016-12-22 14:50:12 +00:00
Leo Hemsted
3ed97151ee fix placeholders not appearing in email subject
it now switches utils.template.Template type, since the base Template
type now no longer has a subject attribute.

updated test case to use `sample_email_template_with_placeholders`
instead of `sample_email_template`
2016-12-22 14:40:33 +00:00
Rebecca Law
531cede6cf Merge pull request #777 from alphagov/log-notification-id-on-provider-call
Log notification ID on deliver tasks and in clients.
2016-12-22 14:09:23 +00:00
Leo Hemsted
bf0abce4a3 update python-client version
also unpin the patch version, since it shouldn't matter what patch
we're on provided that the function signatures are the same
2016-12-22 13:53:33 +00:00