Commit Graph

43 Commits

Author SHA1 Message Date
Rebecca Law
6dc336ad6c Created new queries to return the rate with the sum of billable units for the year totals.
Once we have the new columns in notifications table, the query will need to include the rate multiplier and if the number is international.
The monthly billing query will be built next.
2017-04-28 10:10:48 +01:00
Rebecca Law
266c17dfd6 Do not delete rates 2017-04-24 16:32:23 +01:00
Imdad Ahad
c4fac1d937 Revert "Revert "add DVLA organisations to API"" 2017-04-21 16:05:07 +01:00
Leo Hemsted
c3e56d5d2d Revert "add DVLA organisations to API" 2017-04-20 18:21:56 +01:00
Leo Hemsted
d514d99a67 add DVLA organisations to API
when services are created, they'll have a dvla_org_id of 001, or
HM Government. That can be changed later using a regular update call
2017-04-19 16:31:18 +01:00
Imdad Ahad
73d5ce4f8b Add tests to verify correctness of the switching provider task 2017-02-24 12:23:39 +00:00
Andras Ferencz-Szabo
e10c5e28cd Merge pull request #763 from alphagov/cloudfoundry
Run on Paas
2017-01-17 11:28:38 +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
bandesz
fd66fbd719 Run API on Paas 2017-01-13 10:24:13 +00:00
Leo Hemsted
8bb0261c79 dont let user update prov details version, and refactor tests
the provider details tests were previously very stateful - they
would update a value, and then because provider_details is a "static"
table that is not wiped by the notify_db_session fixture, the tests
were forced to make a second update that reverted that change. if the
test fails for whatever reason, the provider_details table ends up
permanently modified, playing havoc on tests further down the line.

this commit adds the fixture `restore_provider_details` to conftest.
this fixture stores a copy of the contents of ProviderDetails and
ProviderDetailsHistory tables outside of the session, runs the test,
and then clears the table and puts those old values in

this means that the tests have been cleaned up so that they do not
do operations twice in reverse. they've also been cleaned up
generally, including fixture optimisations and such
2016-12-19 17:13:10 +00:00
Leo Hemsted
17cf582502 Merge branch 'master' into active-service 2016-11-10 13:54:02 +00:00
Leo Hemsted
f6de17d6b7 dont let people accidentally delete their local database by forcing it to run against a different DB (ie test_notifications_api) 2016-11-08 17:10:28 +00:00
Leo Hemsted
ed187f7fad remove 500/unplanned exception handlers in test
this means if your code throws an exception, in the test you'll see the full stack trace to help debugging
2016-11-04 16:37:55 +00:00
Leo Hemsted
00b905bef0 use a contextmanager to set config values
so that when later tests run, the config has been restored to its
defaults and we don't end up failing later tests in confusing ways
2016-09-21 17:13:26 +01:00
Leo Hemsted
6ceb80d32f Merge pull request #651 from alphagov/contract-tests
Contract tests
2016-09-05 11:31:29 +01:00
Leo Hemsted
7240df0641 replace mock with unittest.mock 2016-08-31 12:39:11 +01:00
Leo Hemsted
59346d7546 add new client fixture
replaces previous notify_api fixture with the age old:
```
    with notify_api.test_request_context():
        with notify_api.test_client() as client:
```

just runs those two context managers in a yield fixture (new pytest 3.0 feature)
2016-08-30 15:55:27 +01:00
Leo Hemsted
fa3d4413e7 update test requirements
requirements should be kept up to date to ensure we get bug fixes and new features as they come - particularly py.test, which we were running an 18 month old version for, and missing out on some useful xfail and fixture enhancements, among other things
2016-08-30 15:55:23 +01:00
Martyn Inglis
cf3c14dbbd Added job_status to marshmallow
- ensured statues not deleted on test runs
- returns in API call

Merge branch 'add-new-column-to-jobs-for-delayed-sending' into scheduled-delivery-of-jobs

Conflicts:
	app/models.py
2016-08-24 14:35:22 +01:00
Leo Hemsted
a6cd490942 add organisation and branding models
a service now has branding and organisation_id columns, and two new
tables have been aded to reflect these:
* branding is a static types table referring to how a service wants
  their emails to be branded:
    * 'govuk' for GOV UK branding (default)
    * 'org' for organisational branding only
    * 'both' for co-branded output with both
* organisation is a table defining an organisation's branding. this
  contains three entries, all of which are nullable
    * colour - a hex code for a coloured bar on the logo's left
    * logo - relative path for that org's logo image
    * name - the name to display on the right of the logo
2016-08-09 15:59:16 +01:00
Leo Hemsted
2d1babf2bb 'detailed' flag on GET /service/<uuid>
if passed in, returns the service object with additional statistics
dictionary, which will be used in the admin app to populate dashboard
components. A new schema has been created for this to avoid clashing/
causing confusion with the existing schema, which is already used
for PUT/POST as well, and this schema can be easily tailored to
reduce ambiguity and lazy-loading
2016-07-21 14:04:25 +01:00
Leo Hemsted
a355f3e544 add idparametrize pytest decorator
so you can specify test IDs in a reasonable dictionary syntax,
which is useful when the parameters may not be immediately
self-explanatory
2016-07-21 14:04:25 +01:00
Adam Shimali
c29dd23702 Add sms sender to service to be used in sms templates
in place of default numeric short code.

If not present default short code is used.
2016-07-01 15:27:54 +01:00
Leo Hemsted
e9482c7fe1 add new key_type table
* single-column static data table that currently contains two types: 'normal' and 'team'
* key_type foreign-keyed from api_keys
  - must be not null
  - existing rows set to 'normal'
* key_type foreign-keyed from notifications
  - nullable
  - existing rows set to null
* api_key foreign-keyed from notifications
  - nullable
  - existing rows set to null
2016-06-24 15:56:54 +01:00
Leo Hemsted
bffeaa773a Remove db.drop_all from notify_db session fixture to speed up tests
We were dropping all tables at the end of the test run, however the alembic_version table is not part of the metadata so was being persisted. Alembic then doesn't upgrade the database next test run, since the version appears up to date, so we were, in the notify_db_session fixture, recreating from MetaData (sqlalchemy models). This involves quite a costly comparison of the postgres system tables and the tables in models.py, which was adding half a second to each test that uses the notify_db_session fixture (virtually all of them).
2016-06-22 15:22:16 +01:00
Rebecca Law
885abcaf16 Make update notification status transcational.
Refactor methods for reusability.
2016-05-27 12:09:36 +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
Martyn Inglis
42c42bfdc9 Added tests to ensure pick correct provider from the database in the celery tasks. 2016-05-11 14:03:12 +01:00
Martyn Inglis
57e05feafb Updated the Provider stats and rates DAO objects to query based on the identifier in the ProviderDetails object.
- updated all tests
- changed teardown to leave provider details rows on end of individual tests
2016-05-06 09:09:47 +01:00
Nicholas Staples
90f0505a3d Update limit to message_limit.
Further db changes and updates.

Remove traceback print out.

Fix bug in passing template id to a task.
2016-04-11 16:53:40 +01:00
Nicholas Staples
c4b316bde6 Rebased migrations, all tests working. 2016-04-08 13:34:54 +01:00
Nicholas Staples
514d490d2f No limit for live services. 2016-04-01 11:12:44 +01:00
Rebecca Law
67af351f26 Fix get_users_by_service to return 404 if service does not exist.
Refactored service/rest.py so that all methods are returning a properly formatted error message so that the error message can deal with the response.
Refactoed errors.py to properly format the error message.
2016-02-25 12:11:51 +00:00
Rebecca Law
9073814d9f I have an issue with the test, not sure why? 2016-02-17 17:48:23 +00:00
Martyn Inglis
cb265896a7 Merge branch 'master' into move-sms-notifications-into-celery
Conflicts:
	app/__init__.py
	tests/conftest.py
2016-02-17 09:14:37 +00:00
Rebecca Law
08ba5de61b Update config
Source the configuration from an environment file, this way it is similar to how the aws environment works
2016-02-16 16:01:50 +00:00
Martyn Inglis
18d63e241b Extracted serialiser for encryption into a flask module
- allows mocking easier
- shared across methods
- not built everytime
2016-02-16 15:28:30 +00:00
Nicholas Staples
aba1cd2ed5 Sqs queues now populated from all create_notification api calls. Marshmallow schemas added for notification. 2016-02-03 13:16:19 +00:00
Rebecca Law
b5c662eca8 Change services.id to a UUID
Ideally all the primary keys in the db would be UUID in order to guarantee unique ids across distributed dbs.
This updates the services.id to a UUID. All the tables with a foreign key to the services.id are also updated.
The endpoints no longer state a data type of the <service_id> path param.
All the tests are updated to reflect this update.

The thing to pay attention to is the 0011_uuid_service_id.py migration script.
This commit must go with a commit on the notifications_admin app to keep things working.
There will be a small outage until both deploys have happened.
2016-02-02 14:22:22 +00:00
Nicholas Staples
752a359d3d Added versions file for initial db and fixed tests. 2016-01-12 09:56:42 +00:00
Nicholas Staples
5bcc615825 Added dao, test framework and tests for dao. 2016-01-08 12:18:12 +00:00
Nicholas Staples
a327702ad0 Initial code added for models and services not functional yet. Bootstrap and migrations added for db. 2016-01-07 17:50:55 +00:00
Martyn Inglis
6deaa61011 Implement a JWT header into base client
- adds a base client
- adds a notifications client

These do not proxy onto genuine methods. This pull request is the basic implication of the API Client. Still needs a few things before is ready, notably proper logging and actual API endpoints to hook into.

Basic premise is to deliver the JWT tokens required for Notify API authentication so we can discuss the implementation/premise.
2015-12-11 16:57:00 +00:00