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
This commit is contained in:
Leo Hemsted
2017-09-21 11:50:49 +01:00
parent 76106b9f7f
commit e18e78180e
4 changed files with 53 additions and 47 deletions

View File

@@ -172,7 +172,13 @@ def sample_service(
@pytest.fixture(scope='function')
def sample_service_full_permissions(notify_db, notify_db_session):
return sample_service(notify_db, notify_db_session, permissions=SERVICE_PERMISSION_TYPES)
return sample_service(
notify_db,
notify_db_session,
# ensure name doesn't clash with regular sample service
service_name="sample service full permissions",
permissions=SERVICE_PERMISSION_TYPES
)
@pytest.fixture(scope='function')