Commit Graph

116 Commits

Author SHA1 Message Date
Ken Tsang
54d85fd8df Add tests for services with no permissions 2017-05-25 17:48:09 +01:00
Ken Tsang
8488895612 Refactored tests 2017-05-25 17:48:09 +01:00
Ken Tsang
234312ece0 Update service permissions to ensure state in sync 2017-05-25 17:48:09 +01:00
Ken Tsang
2f626fa6fc Add permissions validation in service schema 2017-05-25 17:47:21 +01:00
Ken Tsang
e59a1ab104 Update tests for existing flags to set service permissions 2017-05-25 17:47:21 +01:00
Ken Tsang
8e3e31faaf Updated service DAO and API end points 2017-05-25 17:47:21 +01:00
Leo Hemsted
4b8b6ca91e add test to ensure that updating other things doesnt affect sms sender 2017-05-25 10:37:17 +01:00
Leo Hemsted
554a193cff separate service deserialization from validation
Marshmallow validates and deserialises - BUT, when it deserialises,
it explicitly sets `sms_sender=None`, even when you haven't passed
sms_sender in. This is problematic, because we wanted to take advantage
of sqlalchemy's default value to set sms_sender to `GOVUK` when the
actual DB commit happens.

Instead, still use marshmallow for validating, but manually carry out
the json deserialisation in the model class.

This fixes a bug that only manifested when the database was upgraded,
but the code hadn't updated. 🎉
2017-05-24 16:27:12 +01:00
Leo Hemsted
e9b1fd4dde Revert "Non null sender" 2017-05-23 16:32:03 +01:00
Leo Hemsted
afd748bab2 test no longer applicable as null sms_sender is an error now 2017-05-23 11:43:23 +01:00
Leo Hemsted
47560515dc add upgrade script to remove non-null values from the sender column 2017-05-23 11:33:43 +01:00
Leo Hemsted
147c50f87b set sms_sender to be 'GOVUK' if not otherwise specified
this is a precursor to making the column non-nullable
2017-05-23 11:33:31 +01:00
Leo Hemsted
86c9600b04 use config to get default sender rather than hardcoding
this means that on non-prod envs, it reflects that environment.

it needs to be a lamdba, because the column object is created at import
time, when current_app.config won't have been loaded - this means that
when you create a Service object, that lambda executes and grabs the
correct default value
2017-05-23 11:12:37 +01:00
Leo Hemsted
2535a7fe98 set sms_sender to be 'GOVUK' if not otherwise specified
this is a precursor to making the column non-nullable
2017-05-22 17:13:35 +01:00
minglis
da6a6f6641 Merge pull request #959 from alphagov/comma-format-message-limit
Comma-format number when emailing live services
2017-05-18 11:06:24 +01:00
kentsanggds
c4964d8cf4 Merge pull request #956 from alphagov/add-service-permissions
Add service permissions DAO and refactor user service permission mock
2017-05-16 14:26:15 +01:00
Ken Tsang
3602431c2a Renamed test and refactored fixtures 2017-05-16 13:41:54 +01:00
Chris Hill-Scott
2d4f10bd22 Comma-format number when emailing live services
250,000 is easier to read than 250000.
2017-05-16 12:33:01 +01:00
Ken Tsang
114d4d84d4 Add service permissions DAO and refactor user service permission mock 2017-05-15 17:28:14 +01:00
Imdad Ahad
d993e1a43e Don't send notification if other service attrs changed 2017-05-15 15:02:01 +01:00
Imdad Ahad
5eb02a45a5 Send go live email when service goes live 2017-05-12 14:07:06 +01:00
Leo Hemsted
348183d93b Merge pull request #942 from alphagov/status-as-table
notification status as table
2017-05-10 13:54:49 +01:00
Rebecca Law
a564b9aeb0 Update /service/{}/notifications to look for a "to" query string, if it exists call the search notifications_by_to_field method. 2017-05-08 17:20:21 +01:00
Rebecca Law
d252dc8976 New endpoint to search by "to" field of the notification.
The query ignores case and spaces.
2017-05-05 14:12:50 +01:00
Leo Hemsted
7e52fa4d13 add new notification_status column to models.py
We now have a new column in the database, but it isn't being
populated. The first step is to make sure we update this column,
while still keeping the old enum based column up to date as well.

A couple of changes have had to happen to support this - one irritating
thing is that if we're ever querying columns individually, including
`Notification.status`, then we'll need to give that column a label,
since under the hood it translates to `Notification._status_enum`.
Accessing status through the ORM (i.e., my_noti.status = 'sending' or
similar) will work fine.
2017-05-04 17:24:28 +01:00
Ken Tsang
03885fea2f Update tests with new rates 2017-05-03 13:13:13 +01:00
Ken Tsang
baf84b53d3 Update test to check it doesn't get email usage 2017-04-28 10:10:49 +01:00
Rebecca Law
3b41478a0a Updated Notification model to use Float(asdecimal=False) for rate_mutliplier.
Added test with multiple rows for a month.
2017-04-28 10:10:49 +01:00
Rebecca Law
1a64509186 Change the resultset from the yearly and monthly billing data queries.
Fix some formatting of the return objects.
2017-04-28 10:10:49 +01:00
Rebecca Law
a186fc95be Added new endpoints to return the yearly-usage and monthly-usage for a given financial year and service id.
Since the response has changed I have created new endpoints so that the deployments for Admin are more managable.

Removed print statements from some tests.
2017-04-28 10:10:48 +01:00
Ken Tsang
aed9bc0fe7 Added tests for international sms flag 2017-04-24 13:01:13 +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
76676280ab add create service tests for dvla_org 2017-04-20 17:22:45 +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
Ken Tsang
5f945ab30e Refactored code, changed now to utcnow in test 2017-03-29 11:47:41 +01:00
Ken Tsang
af78efd137 Fix get_detailed_services BST 2017-03-29 11:03:28 +01:00
Leo Hemsted
d639aa22df skip failing timezone test
TODO fixme
2017-03-28 14:02:47 +01:00
Rebecca Law
f880604c85 First attempt at securing the endpoints.
Started with adding a before_request event to the service_blueprint, which executes the requires_admin_auth method rather than the require_auth method.

Obviously this is not done but want to get this in front of people to get an opinion.
2017-03-16 10:42:45 +00:00
Imdad Ahad
36d52c6e42 Add template type to response and refactor 2017-03-08 12:01:38 +00:00
Imdad Ahad
520c588d56 Add endpoint to retreive stats for service by template per month 2017-03-08 12:01:38 +00:00
Chris Hill-Scott
cffd0c2c54 Remove weekly stats endpoints
The weekly stats endpoint wont be used once
https://github.com/alphagov/notifications-admin/pull/1109 has been
merged.

It has been replaced with a new monthly endpoint in
https://github.com/alphagov/notifications-api/pull/807
2017-02-08 13:16:41 +00:00
Leo Hemsted
855a412c90 Merge pull request #812 from alphagov/plat-adm-dates
make sure we convert strings to dates before we use them
2017-01-31 16:24:30 +00:00
Leo Hemsted
cd47dbd36b make sure we convert strings to dates before we use them
fixes 500 on platform admin page
2017-01-31 16:12:46 +00:00
Chris Hill-Scott
56ba653f48 Add endpoint for breakdown of activity by month
This endpoint will eventualy replace the weekly breakdown one. By month
for a given financial year is better, because it gives us consistency
with the breakdown of financial usage (and eventually consistency with
the template usage).

The code to do this is a bit convoluted, in order to fill out the counts
for months and statuses where we don’t have notifications.

This will make the admin side of this easier, because we can rely on
there always being numbers available. The admin side will deal with
summing the statuses (eg `temporary-failure` > `failed`) because this
is presentational.

This commit also modifies the usage count to use `.between()` for
consistency.
2017-01-31 14:16:34 +00:00
Leo Hemsted
0d089a383e fix tests in service/test_rest.py 2017-01-31 12:06:25 +00:00
Chris Hill-Scott
4e60265c58 Add tests for billable unit rest endpoint
Doesn’t do extensive tests through the DAO layer, we have separate tests
elsewhere for that. This just tests the query parameter validation.
2017-01-27 11:47:40 +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
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
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