Commit Graph

344 Commits

Author SHA1 Message Date
Leo Hemsted
57a174aeb4 add tests for org invite rest, and update conftest 2018-02-23 10:45:18 +00:00
Ken Tsang
60f96ab598 Organisation service DAO 2018-02-13 14:06:43 +00:00
Rebecca Law
c54e0d322b A little clean up 2017-12-28 10:58:15 +00:00
Ken Tsang
d0fcfa7d0c Update sample_service_full_perms to leave out letters_as_pdf permissions
- as letters_as_pdf is a temporary service permission until the build dvla file process is deprecated rather than update all the tests to remove the permission so that they pass, lets remove it here instead
2017-12-12 12:07:55 +00:00
Ken Tsang
bc316dd1fe Add reference as part of sample_letter_notification 2017-12-12 12:07:55 +00:00
Ken Tsang
16136317f9 Add letters pdf task 2017-12-12 12:07:55 +00:00
Leo Hemsted
4cdcc4e035 no longer add an annual billing entry creating a service
this is now handled by a separate call from the admin app
2017-12-06 14:45:44 +00:00
Leo Hemsted
b0d4044ff5 remove free_sms_fragment_limit from service
* remove from model
* still required when calling POST /service - we just call through
  from dao_create_service to add a new annual billing entry.
* removed from POST /service/<id> update_service - if you want to
  update/add a new one, use POST /service/<id>/free-sms-fragment-limit
* made sure tests create services with default 250k limit.
2017-12-06 14:45:43 +00:00
Rebecca Law
b0d88ec08c Updates as per review comments 2017-11-28 11:05:56 +00:00
Rebecca Law
530f2e7f6a Update invite user endpoint to set the reply_to_text on the notification.
Update v1 post notifications to set the reply_to_text on the notification.
2017-11-27 12:30:50 +00:00
Chris Hill-Scott
e8a94422e5 Make SMS prefix setting non-nullable
We have now:
- defaulted new services to start with this column set to `true`
- migrated all preexisting services[1] to have either `true` or `false` set
  for this column

There is no way for a service to switch back from `true`/`false` to
`null`.

This means that we can safely enforce a non-nullable constraint on this
column now.

1. There is a little gotcha: the GOV.UK Notify service still relies on
   the `sms_sender` column. It doesn’t have a row in the
   `service_sms_senders` table. This means the previous migration
   never changed this service’s value for `prefix_sms` from `null`. So
   this commit also changes its value to `False`, so that the rest of
   the migration, of the whole column, is possible.
2017-11-16 14:29:32 +00:00
Alexey Bezhan
db1c647873 Remove NotificationHistory.template relationship
Relationship attribute is not used by the application code, so we
can remove it without replacing it with a TemplateHistory one.

This also updates the foreign key constraint to refer to the composite
primary key for the TemplateHistory records.
2017-11-10 15:13:55 +00:00
Alexey Bezhan
c62f2a3f7c Update create_custom_template test helper to create history object
`create_custom_template` is not using `dao_create_template` since
it explicitly sets a template id. Notifications.template relationship
now refers to a TemplateHistory objects, so we need to make sure that
`create_custom_template` creates a matching TemplateHistory record
when it creates a Template.
2017-11-10 15:13:55 +00:00
Alexey Bezhan
94dae42902 Avoid assigning notification.template when creating test objects
`Notification.template` changed from being a Template relationship
to TemplateHistory. When a relationship attribute is being assigned,
SQLAlchemy checks that the assigned value type matches the relationship
type. Since most tests at the moment create a notification using a
Template instance this check fails.

Rewriting the tests to use TemplateHistory objects would require
changes to the majority of tests. Instead, when creating a notification
objects we assign the foreign key attributes directly. This skips the
SQLAlchemy type check, but we still get the constraint check on the
foreign keys, so a matching TemplateHistory object needs to exist in
the database.
2017-11-10 15:12:07 +00:00
kentsanggds
34aa8dfd01 Merge pull request #1373 from alphagov/ken-get-inbound_sms-api
Get inbound SMS API
2017-11-10 10:25:02 +00:00
Leo Hemsted
6af616eb83 add name to personalisation and urlencode next param
also add tests
2017-11-07 16:47:26 +00:00
Leo Hemsted
dd326ec1d3 add new template to config
and rename existing new user email verification template for clarity
2017-11-07 16:47:26 +00:00
Ken Tsang
85b8e24e17 Add V2 inbound_sms API
- had to update the serialization in the model so that the date time is appended with the UTC timezone
- test has been added to ensure that the schema will validate the response correctly
2017-11-07 13:29:40 +00:00
Rebecca Law
f5e79302cd Remove NotificationStatistics
NotificationStatistics was added as a spike but didn't work out as expected. This is finally removing all that unused code.
I'll drop the table in the next PR
2017-11-01 15:02:50 +00:00
Chris Hill-Scott
46d45d8595 Make international SMS on for new services
International SMS is a mature, documented feature now. There’s no reason
it shouldn’t be available to everyone. If it’s turned off by default
then we’re relying on people finding it in the settings page to know
that it exists (which we found in research the other week that users,
who would have benefitted from having international SMS, were failing to
do).

This also fixes the problem whereby users signing up for Notify with an
international phone number (eg those working abroad for the Foreign and
Commonwealth Office) couldn’t get through the tour because they weren’t
able to send themselves the example text message (see
https://www.pivotaltracker.com/story/show/150705515).
2017-10-19 11:43:27 +01:00
Venus Bailey
9b60d69931 Revert "Revert "[#151837054] Add new column free_sms_fragment_limit in the Services table"" 2017-10-16 16:24:34 +01:00
Venus Bailey
616a6f8ef8 Revert "[#151837054] Add new column free_sms_fragment_limit in the Services table" 2017-10-16 12:43:05 +01:00
venusbb
f95282a84d Add column, free_sms_fragment_limit, to services & services_history
- Created new column in both tables
- Modified model and Service schema
- Modifed existing test
2017-10-12 12:16:13 +01:00
Katie Smith
dede336b3b Update tests to not use letter contact block from services table
A few test updates were needed after rebasing onto master.
2017-10-03 13:35:09 +01:00
Imdad Ahad
cb37ba5f78 Update schema to return default letter contact for a service 2017-10-03 10:31:21 +01:00
Chris Hill-Scott
fa8e4b29f2 Return placeholders when getting a template
> Currently when retrieving a template via one of the clients, we do
> not return the personalisation fields that are required for that
> template.
>
> This is useful for services who want to perform template validation on
> their own systems. A service user has also requested this.

– https://www.pivotaltracker.com/story/show/150674476

This commit adds an extra attribute to the JSON response containing an
array of the placeholder names. This key is called "personalisation",
to match the argument that developers use to pass in the values of
placeholders.
2017-09-22 10:00:23 +01:00
Leo Hemsted
e18e78180e update letter tests to use correct service
previously they were using sample_service fixture under the hood, but
with full permissions added - this works fine, **unless** there's
already a service with the name "sample service" in the database. This
can happen for two reasons:

* A previous test didn't tear down correctly
* This test already invoked the sample_service fixture somehow

If this happens, we just return the existing service, without modifying
its values - values that we might change in tests, such as
research mode or letters permissions.

In the future, we'll have to be vigilant! and aware! and careful! to
not use sample_service if we're doing tests involving letters, since
they create a service with a different name now
2017-09-21 11:50:49 +01:00
Chris Hill-Scott
29a962060f Return delivery estimate for letter notifications
> For get all or get one letter the response needs to be updated so that
> it looks similar to admin app.
>
> status: created|sending --> received letter
> new column: `estimated delivery date`: derived from created at date.
> (see how the admin app is doing it)
>
> NOTE:
> At the moment we only have 2 statuses for a letter created and
> sending, but we will want to have other internal statuses that make
> sense to the Notify team but not our services. When we know those
> statuses the status map will be updated at that point.

– https://www.pivotaltracker.com/story/show/150512525

This commit implements the date (not status) part of this story.
2017-09-15 14:58:07 +01:00
Rebecca Law
e32abb0ada Merge pull request #1221 from alphagov/ken-no-letters-when-trial
Stop letters when service is in trial
2017-09-05 15:33:50 +01:00
Imdad Ahad
72de309b26 Make perf platform processing stats query the NotificationHistory table 2017-08-31 12:52:59 +01:00
Ken Tsang
7e70b44113 Error in task when letter template and in trial mode 2017-08-30 16:04:10 +01:00
Ken Tsang
fbe1a14304 Removed create_inbound_numberfrom fixture 2017-08-16 14:23:32 +01:00
Ken Tsang
c36423aac6 Refactor code for dao_fetch_servies_by_sms_sender to use inbound_numbers
This will need to be refactored after the deployment of api and admin and after the update script for existing services using inbound numbers has been executed.
2017-08-16 12:51:31 +01:00
Ken Tsang
104fc93503 Refactor code 2017-08-16 12:50:44 +01:00
Ken Tsang
d5b91f9911 Fixed admin_request bug 2017-08-16 12:50:44 +01:00
Ken Tsang
468048797a Refactor conftest 2017-08-16 12:50:44 +01:00
Ken Tsang
e80bc9deb2 Refactor conftest 2017-08-11 12:56:59 +01:00
Ken Tsang
c9f871c0c9 Refatored tests and fixtures for inbound_number 2017-08-11 12:56:59 +01:00
Ken Tsang
3c392596a3 Add backref in InboundNumber model 2017-08-11 12:56:59 +01:00
Leo Hemsted
372b10f19c fix up tests to be internally consistent
notifications should always have at least one of job and api key, and
the key type should match the api key's key type (or be 'normal')
2017-08-02 15:35:56 +01:00
Leo Hemsted
11458c421b ensure permissions are correct in sample letter fixtures
sample_letter_* should always include a service that has letter
permissions.

Also, print out the JSON response in the admin_request fixture if the
response code doesn't match
2017-07-27 11:12:09 +01:00
Ken Tsang
5a82fe0a70 Add inbound sms permission check 2017-07-06 12:31:01 +01:00
Ken Tsang
e927723726 Update sms/email permission tests error msg 2017-07-06 12:27:57 +01:00
Ken Tsang
c1caa4a5da Add tests for when email / sms disabled 2017-07-06 12:27:56 +01:00
Ken Tsang
98cd838510 ken-use-only-new-service-permissions 2017-07-06 12:27:55 +01:00
Leo Hemsted
88a479a4bb make client request fixture args conform 2017-06-20 12:06:49 +01:00
Imdad Ahad
1dacc6c3a3 Updates:
* Skip the decorated tests as that doesn't work as we expect
* Remove magic numbers in tests
2017-06-13 15:22:31 +01:00
Imdad Ahad
6b4597149f Add filter to get jobs to delete (sms, email, letter) 2017-06-06 16:01:27 +01:00
Leo Hemsted
d89cb2c120 add an admin_request fixture
this gets rid of some boilerplate around mocking requests
from the front-end
2017-06-02 15:19:24 +01:00
kentsanggds
263adac805 Merge pull request #984 from alphagov/ken-update-api-service-permissions-handling
Ken update api service permissions handling
2017-05-26 14:39:27 +01:00