Commit Graph

318 Commits

Author SHA1 Message Date
Steven Reilly
ff4190a8eb Remove letters-related code (#175)
This deletes a big ol' chunk of code related to letters. It's not everything—there are still a few things that might be tied to sms/email—but it's the the heart of letters function. SMS and email function should be untouched by this.

Areas affected:

- Things obviously about letters
- PDF tasks, used for precompiling letters
- Virus scanning, used for those PDFs
- FTP, used to send letters to the printer
- Postage stuff
2023-03-02 20:20:31 -05:00
Ryan Ahearn
041cd08097 Clean up more mmg and firetext references 2022-12-22 09:31:12 -05:00
stvnrlly
d4e156e8ae Merge branch 'main' into stvnrlly-remove-broadcasts 2022-10-20 19:44:20 -04:00
stvnrlly
53204c307b tests are, uh, mostly passing 2022-10-05 01:12:35 +00:00
stvnrlly
57f4df8ed1 remove broadcast-related code, except migrations 2022-10-04 15:28:27 +00:00
jimmoffet
f1aec54665 clean up comments and method dupes 2022-09-15 15:48:37 -07:00
jimmoffet
b0f819dbd9 canada UK ses callbacks monster mash 2022-09-15 14:59:13 -07:00
Christa Hartsock
af6495cd4c Get tests passing locally
When we cloned the repository and started making modifications, we
didn't initially keep tests in step. This commit tries to get us to a
clean test run by skipping tests that are failing and removing some
that we no longer expect to use (MMG, Firetext), with the intention that
we will come back in future and update or remove them as appropriate.

To find all tests skipped, search for `@pytest.mark.skip(reason="Needs
updating for TTS:`. There will be a brief description of the work that
needs to be done to get them passing, if known. Delete that line to make
them run in a standard test run (`make test`).
2022-07-07 15:41:15 -07:00
Leo Hemsted
6181c60f75 remove usage of notify_db fixture in unit tests
* notify_db fixture creates the database connection and ensures the test
  db exists and has migrations applied etc. It will run once per session
  (test run).
* notify_db_session fixture runs after your test finishes and deletes
  all non static (eg type table) data.

In unit tests that hit the database (ie: most of them), 99% of the time
we will need to use notify_db_session to ensure everything is reset. The
only time we don't need to use it is when we're querying things such as
"ensure get X works when database is empty". This is such a low
percentage of tests that it's easier for us to just use
notify_db_session every time, and ensure that all our tests run much
more consistently, at the cost of a small bit of performance when
running tests.

We used to use notify_db to access the session object for manually
adding, committing, etc. To dissuade usage of that fixture I've moved
that to the `notify_db_session`. I've then removed all uses of notify_db
that I could find in the codebase.

As a note, if you're writing a test that uses a `sample_x` fixture, all
of those fixtures rely on notify_db_session so you'll get the teardown
functionality for free. If you're just calling eg `create_x` db.py
functions, then you'll need to make you add notify_db_session fixture to
your test, even if you aren't manually accessing the session.
2022-05-04 11:36:54 +01:00
Leo Hemsted
51646af92e remove provider_rates table
this was added five years ago but never used. if we want to bring back
variable rates per client we might as well get a fresh start since a lot
has changed since then.
2022-05-03 14:42:59 +01:00
Pea Tyczynska
124562b50a Refactor creating nhs branding in tests into a fixture 2022-04-19 12:25:17 +01:00
Pea Tyczynska
b6dd189462 Test cancel request via API returns 404 if service id does not match 2022-01-20 18:28:10 +00:00
Ben Thorner
4d05b064fd Remove redundant DB fixtures in conftest.py
These were only there to ensure a DB session existed for the test
and are now included implicitly as one of the dependencies of the
"sample_user" fixture.
2021-09-14 09:37:32 +01:00
Ben Thorner
c9ea85938a Refactor "create_user" to actually create a user
This switches a number of fixtures to use "sample_user", which is
equivalent to calling the previous "create_user" function when it
used to default the email to "notify@...".
2021-09-14 09:29:28 +01:00
Ben Thorner
0312e2a528 Split generating authorization headers by type
In response to [1].

[1]: https://github.com/alphagov/notifications-api/pull/3300#discussion_r681653248
2021-08-04 15:13:52 +01:00
Ben Thorner
2b292ebd16 Refactor "notify_service" function into a fixture
This means we can use it in the next commit. Also, it was surprising
for the function to be returning a tuple of values, instead of just
the service object. Since the consumers of the function only needed
the user as auditing data, it's fine to use the first team member.
2021-06-25 17:46:07 +01:00
Rebecca Law
f3fdd3b09b Add internation api key for firetext.
We want to start using Firetext for sending international SMS. They
require us to use a different API key for international SMS because it
requires a new code path to switch the sender ID to something that the
country will accept.
This PR does not include switching the sender of international SMS to
Firetext but sets us up to do so.
2021-04-20 13:58:55 +01:00
Ben Thorner
a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
Pea Tyczynska
e0c73ac342 Send daily email with letter and sheet volumes to DVLA 2021-02-23 15:13:19 +00:00
Katie Smith
c59e0091ee Stop emailing Notify when an MOU is signed
We've decided we don't get any value from these emails any more, so this
stops us (Notify support) receiving them. We still let teams know an MOU
has been signed.
2021-02-18 09:07:19 +00:00
David McDonald
6fcda6debb Make set_as_broadcast_service use a single DB commit
We don't want things in a half state if there is an error during the
method. Therefore, we move it all into a single function that is wrapped
in a transaction.

Note, we copy the approach of
https://github.com/alphagov/notifications-api/blob/master/app/dao/services_dao.py#L293
by having a single new dao function that does all the DB work.
2021-02-16 10:31:11 +00:00
David McDonald
9f4b82f074 Make service a member of the broadcast organisation
We will use this to easily identify all our broadcast services. There
could be other ways to deal with finding and seeing all broadcast
services but this is a good and easy way to start.
2021-02-16 10:31:06 +00:00
David McDonald
cdcbd1e238 Set count as live to false for broadcast services
We think it would be a security risk to show the name of services
involved in emergency alerts as they be responsible for things such as
counter terrorism.

On top of that, showing broadcast services in the list of all services
could enable someone to use that information to try and trick an admin
into letting them access of a particular service given the fact they
know the name of it
2021-02-16 10:31:05 +00:00
David McDonald
16ee040923 Add service broadcast settings to sample_broadcast_service
This will make our `sample_broadcast_service` look more realistic.

The one downside to this, is that there will be a short amount of time
where we have broadcast services that do not have a row in the
service_broadcast_settings table until we have backfilled this data. Our
unit tests therefore won't have coverage for this case but I think the
risk is small and acceptable for the moment as this will no longer be
the case in say a weeks time.
2021-02-16 10:31:02 +00:00
Pea Tyczynska
deb360846d Mark letters from insolvency service
So that DVLA knows to process them separately to avoid issues.
2020-10-21 16:56:18 +01:00
David McDonald
f9911c7965 Send broadcast invite email for broadcast service invites
This means the copy is more accurate and mentions sending emergency
alerts rather than previous copy about sending emails texts and letters.
2020-09-15 16:47:41 +01:00
David McDonald
23ac7bcf56 Use sample broadcast service instead of sample service for tests
We only want to use a service that has permissions for broadcasts to
make our tests more realistic
2020-09-15 16:47:41 +01:00
Chris Hill-Scott
65346852ed Rename variables and functions in tests
To reflect the new name of the feature.
2020-07-28 12:56:32 +01:00
Chris Hill-Scott
083573e4dc Rename model
Reflects the new name of the feature.

Note that the name of the underlying table hasn’t changed because it’s
explicitly set to `service_whitelist`. Changing this will be a more
involved process.
2020-07-28 12:56:04 +01:00
Rebecca Law
a13bcc6697 Reduce the pressure on the db for API post email requests.
Instead of saving the email notification to the db add it to a queue to save later.
This is an attempt to alleviate pressure on the db from the api requests.
This initial PR is to trial it see if we see improvement in the api performance an a reduction in queue pool errors. If we are happy with this we could remove the hard coding of the service id.

In a nutshell:
 - If POST /v2/notification/email is from our high volume service (hard coded for now) then create a notification to send to a queue to persist the notification to the db.
 - create a save_api_email task to persist the notification
 - return the notification
 - New worker app to process the save_api_email tasks.
2020-03-25 07:59:05 +00:00
Leo Hemsted
48a735c58c remove unused fixture 2019-12-13 10:02:39 +00:00
Katie Smith
544a7a2311 Remove parameters from fixtures
Since Pytest 4, we can't call fixtures as if they were functions. This
change removes the parameters from the fixtures (since we can't use
them), except for when the parameter is another fixture.
2019-11-01 14:34:15 +00:00
Katie Smith
6411e10d7b Remove unused fixtures 2019-11-01 13:18:07 +00:00
Katie Smith
87d7ed21a2 Fix fixtures
Stopped 2 fixtures from calling other fixtures as functions and causing
errors.
2019-10-31 15:04:23 +00:00
Katie Smith
fb875c50c1 Stop fixtures in conftest from calling other fixtures
Stopped some the fixtures in conftest.py from calling other
fixtures as functions to make them Pytest 4 compliant.
2019-10-30 11:22:36 +00:00
Katie Smith
99c3837dc1 Fix the fixtures for templates lacking certain permissions
These fixtures were both calling other fixtures as functions and being
called as functions in the tests. Rewriting the tests to make them
Pytest 4 compatible means we are no longer using
`sample_template_without_letter_permission`, so this has been deleted.
2019-10-30 11:22:36 +00:00
Katie Smith
a2c25cec9f Make a couple of fixtures Pytest 4 compliant
By stopping them from calling other fixtures as functions.
2019-09-18 12:01:20 +01:00
Katie Smith
62735ea125 Remove sample_notification_with_api_key fixture
This was only used once and was not Pytest 4 compatible.
2019-09-18 11:04:24 +01:00
Pea Tyczynska
9dfc550f46 Add org types table 2019-07-18 17:05:22 +01:00
Leo Hemsted
a0c0dec429 add tests
include dynamically loading the template contents from the alembic upgrade file itself
2019-07-12 15:14:13 +01:00
Rebecca Law
1f9aade749 - Adding test where post_notification can't send to a member outside of the team or whitelist.
- Updating some tests to be pytest4 compliant.
2019-06-11 16:45:35 +01:00
Katie Smith
844f22bcd0 Remove unused fixture and add test function to create permissions 2019-06-05 14:54:52 +01:00
Pea Tyczynska
615ea6a98a Send verifcation email to a new reply-to email address 2019-05-23 15:36:09 +01:00
Alexey Bezhan
330afab5e2 Make Firetext URL configurable through the application environment
Similar to MMG, there's a new env variable FIRETEXT_URL that can be
used to override the Firetext api URL.

This will be used to stub out both providers during the load test or
can be used to run a local API against a fake provider endpoint.
2019-04-12 12:03:58 +01:00
Katie Smith
31ddd36e2c Update invited user tests to take folder_permissions into account 2019-03-22 09:30:39 +00:00
Pea Tyczynska
211d3741ba Send confirmation emails to users when team manager edits their
email address  or mobile number.
2019-02-26 16:30:29 +00:00
Pea Tyczynska
8ef581de69 Remove service.postage and choose_postage permission from the code and tests 2019-02-11 18:20:34 +00:00
Pea Tyczynska
5b9e6c2086 Set postage on basis of postage argument or template postage 2019-02-06 13:23:09 +00:00
Pea Tyczynska
eea324a19d Add flag on create_service to decide whether we should also check if service exists 2019-01-03 10:57:29 +00:00
Pea Tyczynska
f79c0b03e7 Sample job uses create_template instead of sample template 2019-01-03 10:52:14 +00:00