Commit Graph

313 Commits

Author SHA1 Message Date
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
Imdad Ahad
77b82305f4 Search normalised in get_notifications_for_service:
* Use dao method to search against normalised(recipient)
* Add filter to accept one or more statuses
2017-05-26 11:58:50 +01:00
Ken Tsang
234312ece0 Update service permissions to ensure state in sync 2017-05-25 17:48:09 +01:00
Rebecca Law
383dee3bb2 Updated the serialization of Notification.scheduled_for to include minutes. 2017-05-24 14:52:32 +01:00
Rebecca Law
9bfba52f53 Add pending flag to scheduled_notifications.
Set pending flag to false when the notification has been sent to provider task.
2017-05-22 15:07:16 +01:00
Rebecca Law
3a3161ecc4 Merge branch 'master' into schedule-api-notification
Conflicts:
	app/celery/scheduled_tasks.py
	app/v2/notifications/post_notifications.py
	tests/app/celery/test_scheduled_tasks.py
2017-05-22 14:05:57 +01:00
Rebecca Law
973cc2c4c9 Changed the scheduled_for datetime to only send and hour of a day to send.
Also expect the date being passed in is BST. The date is converted to UTC before saving. And converted to BST when returning a notification.
2017-05-17 15:06:15 +01:00
Ken Tsang
733c16b2bb Update to strip down DAO and clarify tests 2017-05-16 12:33:27 +01:00
Ken Tsang
114d4d84d4 Add service permissions DAO and refactor user service permission mock 2017-05-15 17:28:14 +01:00
Rebecca Law
f0e2713bef Add scheduled_for in the post notification request form.
Return scheduled for in get_notification requests.
2017-05-15 17:27:38 +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
Martyn Inglis
2a0f8c8808 Validate International phone numbers
- uses new utils methods to validate phone numbers
- defaults to International=True on validation. This ensures the validator works on all numbers
- Then check if the user can send this message to the number internationally if needed.
2017-04-26 15:56:45 +01:00
Imdad Ahad
9fbd43c072 Serialise notifications for csv separately:
* Introduces separate method on Notification to serialise the notification
* ready for csv output
* Fixes issue where job_row_number = 0 not being accounted for correctly
2017-04-20 11:52:00 +01:00
Chris Hill-Scott
e47a008dd9 Pass through contact block from service to letter
Whatever a user has entered for their service’s contact block should
appear in the right place in the file we give to DVLA.

The work to output in the right fields in the DVLA file has already been
done. We just weren’t passing it through. This commit passes it through.
2017-04-03 13:27:47 +01:00
Rebecca Law
37a5ce601a Update the version of notifications-utils.
There was a problem with the address block for the DVLATemplate.

Added a countdown to the build_dvla_file.
2017-03-24 15:25:02 +00:00
imdadahad
c11f4b5d5d Merge pull request #829 from alphagov/feat-add-endpoint-for-service-monthly-usage-stats
Add endpoint for service monthly usage stats by template
2017-03-09 16:12:22 +00:00
Imdad Ahad
a4dc614ef7 Restore dao_create_template and use custom template fixture instead 2017-03-08 13:03:44 +00:00
Imdad Ahad
8272a4388d Add dao method to get template stats per month in financial year for service 2017-03-08 12:01:38 +00:00
Imdad Ahad
fe2ccb2222 Remove unused import and ensure provider details are restored after test 2017-03-03 10:54:20 +00:00
Imdad Ahad
eafe8269ef Simplify dao method and update tests and fixtures 2017-02-24 13:39:58 +00:00
Imdad Ahad
73d5ce4f8b Add tests to verify correctness of the switching provider task 2017-02-24 12:23:39 +00:00
Imdad Ahad
60f63a30db Add dao method to get count of slow delivery notifications by provider 2017-02-24 12:23:39 +00:00
Rebecca Law
f56824adde Cancel job if the service is inactive.
Update the PermissionsDao.get_permissions_by_user_id to only return permissions for active services,
this will make the admin app return a 403 if someone (otherthan platform admin) tries to look at an inactive service.
Removed the active flag in sample_service the dao_create_service overiddes this attribute.
2017-02-02 11:34:00 +00:00
Leo Hemsted
1650fb0807 Merge pull request #797 from alphagov/persist-letters
Persist letters
2017-01-30 14:24:38 +00:00
Imdad Ahad
b6cc5b00ba Add dao method to get sms and email notification counts for a date range and previous day 2017-01-27 12:22:36 +00:00
Leo Hemsted
4f238d241a persist_letter saves address correctly to database
the `to` field stores either the phone number or the email address
of the recipient - it's a bit more complicated for letters, since
there are address lines 1 through 6, and a postcode. In utils, they're
stored alongside the personalisation, and we have to ensure that when
we persist to the database we keep as much parity with utils to make
our work easier. Aside from sending, the `to` field is also used to
show recipients on the front end report pages - we've decided that the
best thing to store here is address_line_1 - which is probably going to
be either a person's name, company name, or PO box number

Also, a lot of tests and test cleanup - I added create_template and
create_notification functions in db.py, so if you're creating new
fixtures you can use these functions, and you won't need to pass
notify_db and notify_db_session around, huzzah!

also removed create param from sample_notification since it's not used
anywhere
2017-01-24 12:32:20 +00:00
imdadahad
c3a9d6d5ed Merge pull request #795 from alphagov/switch-providers-on-error
Auto-switch providers on error
2017-01-24 10:58:50 +00:00
Imdad Ahad
d466265a9d Refactor provider switch methods in dao and tests 2017-01-20 16:13:13 +00:00
Chris Hill-Scott
6e6d471cda Don’t strip HTML when saving templates
Right now we strip HTML from templates at the point of saving them. This
also converts stuff like ampersands to their entity form (eg &) and
this is what we save in the database.

This is a bad idea when you’re sending a text message or a letter, in
which an HTML entity makes no sense. But we still need to encode HTML in
the body of HTML emails.

The right place to do this is when rendering the templates. The code to
do this is now in utils. So this commit:
- pull in this new utils code
- removes the old
- adds some integration tests to make sure that everything is working
  as expected (more thorough unit tests are happening in utils)
2017-01-19 12:05:28 +00:00
Imdad Ahad
2896ed27f2 Add dao methods to retrieve providers, switch, toggle along with tests 2017-01-17 15:38:54 +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
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