change dashboard test to reflect demo changes to uploads view

This commit is contained in:
jimmoffet
2022-09-09 17:02:48 -07:00
parent 740470f6bd
commit 69abec0bb3
28 changed files with 127 additions and 183 deletions

View File

@@ -4,4 +4,4 @@ import os
def extract_cloudfoundry_config():
vcap_services = json.loads(os.environ['VCAP_SERVICES'])
os.environ['REDIS_URL'] = vcap_services['aws-elasticache-redis'][0]['credentials']['uri']
os.environ['REDIS_URL'] = vcap_services['aws-elasticache-redis'][0]['credentials']['uri'].replace('redis', 'rediss')

View File

@@ -419,7 +419,7 @@ def get_monthly_usage_breakdown(year, monthly_usage):
def get_monthly_usage_breakdown_for_letters(monthly_letters):
postage_order = {'first class': 0, 'second class': 1, 'international': 2}
group_key = lambda row: ( # noqa: E731
def group_key(row): return ( # noqa: E731
postage_order[get_monthly_usage_postage_description(row)], row['rate']
)

View File

@@ -1,4 +1,4 @@
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
class BroadcastMessageAPIClient(NotifyAdminAPIClient):
@@ -34,18 +34,18 @@ class BroadcastMessageAPIClient(NotifyAdminAPIClient):
def get_broadcast_messages(self, service_id):
return self.get(f'/service/{service_id}/broadcast-message')['broadcast_messages']
# @cache.set('service-{service_id}-broadcast-message-{broadcast_message_id}')
@cache.set('service-{service_id}-broadcast-message-{broadcast_message_id}')
def get_broadcast_message(self, *, service_id, broadcast_message_id):
return self.get(f'/service/{service_id}/broadcast-message/{broadcast_message_id}')
# @cache.delete('service-{service_id}-broadcast-message-{broadcast_message_id}')
@cache.delete('service-{service_id}-broadcast-message-{broadcast_message_id}')
def update_broadcast_message(self, *, service_id, broadcast_message_id, data):
self.post(
f'/service/{service_id}/broadcast-message/{broadcast_message_id}',
data=data,
)
# @cache.delete('service-{service_id}-broadcast-message-{broadcast_message_id}')
@cache.delete('service-{service_id}-broadcast-message-{broadcast_message_id}')
def update_broadcast_message_status(self, status, *, service_id, broadcast_message_id):
data = _attach_current_user({
'status': status,

View File

@@ -1,20 +1,20 @@
from app.notify_client import NotifyAdminAPIClient
from app.notify_client import NotifyAdminAPIClient, cache
class EmailBrandingClient(NotifyAdminAPIClient):
# @cache.set('email_branding-{branding_id}')
@cache.set('email_branding-{branding_id}')
def get_email_branding(self, branding_id):
return self.get(url='/email-branding/{}'.format(branding_id))
# @cache.set('email_branding')
@cache.set('email_branding')
def get_all_email_branding(self, sort_key=None):
brandings = self.get(url='/email-branding')['email_branding']
if sort_key and sort_key in brandings[0]:
brandings.sort(key=lambda branding: branding[sort_key].lower())
return brandings
# @cache.delete('email_branding')
@cache.delete('email_branding')
def create_email_branding(self, logo, name, text, colour, brand_type):
data = {
"logo": logo,
@@ -25,8 +25,8 @@ class EmailBrandingClient(NotifyAdminAPIClient):
}
return self.post(url="/email-branding", data=data)
# @cache.delete('email_branding')
# @cache.delete('email_branding-{branding_id}')
@cache.delete('email_branding')
@cache.delete('email_branding-{branding_id}')
def update_email_branding(self, branding_id, logo, name, text, colour, brand_type):
data = {
"logo": logo,

View File

@@ -1,4 +1,4 @@
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
from app.utils.user_permissions import (
all_ui_permissions,
translate_permissions_from_ui_to_db,
@@ -64,8 +64,8 @@ class InviteApiClient(NotifyAdminAPIClient):
self.post(url='/service/{0}/invite/{1}'.format(service_id, invited_user_id),
data=data)
# @cache.delete('service-{service_id}')
# @cache.delete('user-{invited_user_id}')
@cache.delete('service-{service_id}')
@cache.delete('user-{invited_user_id}')
def accept_invite(self, service_id, invited_user_id):
data = {'status': 'accepted'}
self.post(url='/service/{0}/invite/{1}'.format(service_id, invited_user_id),

View File

@@ -84,7 +84,7 @@ class JobApiClient(NotifyAdminAPIClient):
url=f'/service/{service_id}/job/scheduled-job-stats'
)
# @cache.set('has_jobs-{service_id}')
@cache.set('has_jobs-{service_id}')
def has_jobs(self, service_id):
return bool(self.get_jobs(service_id)['data'])
@@ -108,14 +108,14 @@ class JobApiClient(NotifyAdminAPIClient):
return job
# @cache.delete('has_jobs-{service_id}')
@cache.delete('has_jobs-{service_id}')
def cancel_job(self, service_id, job_id):
return self.post(
url='/service/{}/job/{}/cancel'.format(service_id, job_id),
data={}
)
# @cache.delete('has_jobs-{service_id}')
@cache.delete('has_jobs-{service_id}')
def cancel_letter_job(self, service_id, job_id):
return self.post(
url='/service/{}/job/{}/cancel-letter-job'.format(service_id, job_id),

View File

@@ -1,17 +1,17 @@
from app.notify_client import NotifyAdminAPIClient
from app.notify_client import NotifyAdminAPIClient, cache
class LetterBrandingClient(NotifyAdminAPIClient):
# @cache.set('letter_branding-{branding_id}')
@cache.set('letter_branding-{branding_id}')
def get_letter_branding(self, branding_id):
return self.get(url='/letter-branding/{}'.format(branding_id))
# @cache.set('letter_branding')
@cache.set('letter_branding')
def get_all_letter_branding(self):
return self.get(url='/letter-branding')
# @cache.delete('letter_branding')
@cache.delete('letter_branding')
def create_letter_branding(self, filename, name):
data = {
"filename": filename,
@@ -19,8 +19,8 @@ class LetterBrandingClient(NotifyAdminAPIClient):
}
return self.post(url="/letter-branding", data=data)
# @cache.delete('letter_branding')
# @cache.delete('letter_branding-{branding_id}')
@cache.delete('letter_branding')
@cache.delete('letter_branding-{branding_id}')
def update_letter_branding(self, branding_id, filename, name):
data = {
"filename": filename,

View File

@@ -3,16 +3,16 @@ from itertools import chain
from notifications_python_client.errors import HTTPError
from app.extensions import redis_client
from app.notify_client import NotifyAdminAPIClient
from app.notify_client import NotifyAdminAPIClient, cache
class OrganisationsClient(NotifyAdminAPIClient):
# @cache.set('organisations')
@cache.set('organisations')
def get_organisations(self):
return self.get(url='/organisations')
# @cache.set('domains')
@cache.set('domains')
def get_domains(self):
return list(chain.from_iterable(
organisation['domains']
@@ -22,7 +22,7 @@ class OrganisationsClient(NotifyAdminAPIClient):
def get_organisation(self, org_id):
return self.get(url='/organisations/{}'.format(org_id))
# @cache.set('organisation-{org_id}-name')
@cache.set('organisation-{org_id}-name')
def get_organisation_name(self, org_id):
return self.get_organisation(org_id)['name']
@@ -36,7 +36,7 @@ class OrganisationsClient(NotifyAdminAPIClient):
return None
raise error
# @cache.delete('organisations')
@cache.delete('organisations')
def create_organisation(self, name, crown, organisation_type, agreement_signed):
return self.post(
url="/organisations",
@@ -48,8 +48,8 @@ class OrganisationsClient(NotifyAdminAPIClient):
}
)
# @cache.delete('domains')
# @cache.delete('organisations')
@cache.delete('domains')
@cache.delete('organisations')
def update_organisation(self, org_id, cached_service_ids=None, **kwargs):
api_response = self.post(url="/organisations/{}".format(org_id), data=kwargs)
@@ -61,9 +61,9 @@ class OrganisationsClient(NotifyAdminAPIClient):
return api_response
# @cache.delete('service-{service_id}')
# @cache.delete('live-service-and-organisation-counts')
# @cache.delete('organisations')
@cache.delete('service-{service_id}')
@cache.delete('live-service-and-organisation-counts')
@cache.delete('organisations')
def update_service_organisation(self, service_id, org_id):
data = {
'service_id': service_id
@@ -76,7 +76,7 @@ class OrganisationsClient(NotifyAdminAPIClient):
def get_organisation_services(self, org_id):
return self.get(url="/organisations/{}/services".format(org_id))
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def remove_user_from_organisation(self, org_id, user_id):
return self.delete(f'/organisations/{org_id}/users/{user_id}')

View File

@@ -1,9 +1,9 @@
from app.notify_client import NotifyAdminAPIClient
from app.notify_client import NotifyAdminAPIClient, cache
class PerformanceDashboardAPIClient(NotifyAdminAPIClient):
# @cache.set('performance-stats-{start_date}-to-{end_date}', ttl_in_seconds=3600)
@cache.set('performance-stats-{start_date}-to-{end_date}', ttl_in_seconds=3600)
def get_performance_dashboard_stats(
self,
*,

View File

@@ -3,11 +3,11 @@ from datetime import datetime
from notifications_utils.clients.redis import daily_limit_cache_key
from app.extensions import redis_client
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
class ServiceAPIClient(NotifyAdminAPIClient):
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def create_service(
self,
service_name,
@@ -32,7 +32,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
data = _attach_current_user(data)
return self.post("/service", data)['data']['id']
# @cache.set('service-{service_id}')
@cache.set('service-{service_id}')
def get_service(self, service_id):
"""
Retrieve a service.
@@ -64,7 +64,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
params_dict['only_active'] = True
return self.get_services(params_dict)
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def update_service(
self,
service_id,
@@ -114,7 +114,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
endpoint = "/service/{0}".format(service_id)
return self.post(endpoint, data)
# @cache.delete('live-service-and-organisation-counts')
@cache.delete('live-service-and-organisation-counts')
def update_status(self, service_id, live):
return self.update_service(
service_id,
@@ -123,7 +123,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
go_live_at=str(datetime.utcnow()) if live else None
)
# @cache.delete('live-service-and-organisation-counts')
@cache.delete('live-service-and-organisation-counts')
def update_count_as_live(self, service_id, count_as_live):
return self.update_service(
service_id,
@@ -134,24 +134,24 @@ class ServiceAPIClient(NotifyAdminAPIClient):
def update_service_with_properties(self, service_id, properties):
return self.update_service(service_id, **properties)
# @cache.delete('service-{service_id}')
# @cache.delete('service-{service_id}-templates')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete('service-{service_id}-templates')
@cache.delete_by_pattern('service-{service_id}-template-*')
def archive_service(self, service_id, cached_service_user_ids):
if cached_service_user_ids:
redis_client.delete(*map('user-{}'.format, cached_service_user_ids))
return self.post('/service/{}/archive'.format(service_id), data=None)
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def suspend_service(self, service_id):
return self.post('/service/{}/suspend'.format(service_id), data=None)
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def resume_service(self, service_id):
return self.post('/service/{}/resume'.format(service_id), data=None)
# @cache.delete('service-{service_id}')
# @cache.delete('user-{user_id}')
@cache.delete('service-{service_id}')
@cache.delete('user-{user_id}')
def remove_user_from_service(self, service_id, user_id):
"""
Remove a user from a service
@@ -162,7 +162,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
data = _attach_current_user({})
return self.delete(endpoint, data)
# @cache.delete('service-{service_id}-templates')
@cache.delete('service-{service_id}-templates')
def create_service_template(self, name, type_, content, service_id, subject=None, process_type='normal',
parent_folder_id=None):
"""
@@ -187,8 +187,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
endpoint = "/service/{0}/template".format(service_id)
return self.post(endpoint, data)
# @cache.delete('service-{service_id}-templates')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}-templates')
@cache.delete_by_pattern('service-{service_id}-template-*')
def update_service_template(
self, id_, name, type_, content, service_id, subject=None, process_type=None
):
@@ -214,8 +214,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
endpoint = "/service/{0}/template/{1}".format(service_id, id_)
return self.post(endpoint, data)
# @cache.delete('service-{service_id}-templates')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}-templates')
@cache.delete_by_pattern('service-{service_id}-template-*')
def redact_service_template(self, service_id, id_):
return self.post(
"/service/{}/template/{}".format(service_id, id_),
@@ -224,8 +224,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
),
)
# @cache.delete('service-{service_id}-templates')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}-templates')
@cache.delete_by_pattern('service-{service_id}-template-*')
def update_service_template_sender(self, service_id, template_id, reply_to):
data = {
'reply_to': reply_to,
@@ -236,15 +236,15 @@ class ServiceAPIClient(NotifyAdminAPIClient):
data
)
# @cache.delete('service-{service_id}-templates')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}-templates')
@cache.delete_by_pattern('service-{service_id}-template-*')
def update_service_template_postage(self, service_id, template_id, postage):
return self.post(
"/service/{0}/template/{1}".format(service_id, template_id),
_attach_current_user({'postage': postage})
)
# @cache.set('service-{service_id}-template-{template_id}-version-{version}')
@cache.set('service-{service_id}-template-{template_id}-version-{version}')
def get_service_template(self, service_id, template_id, version=None):
"""
Retrieve a service template.
@@ -256,7 +256,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
endpoint = '{base}/version/{version}'.format(base=endpoint, version=version)
return self.get(endpoint)
# @cache.set('service-{service_id}-template-{template_id}-versions')
@cache.set('service-{service_id}-template-{template_id}-versions')
def get_service_template_versions(self, service_id, template_id):
"""
Retrieve a list of versions for a template
@@ -273,7 +273,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
"""
return self.get('/service/{}/template/precompiled'.format(service_id))
# @cache.set('service-{service_id}-templates')
@cache.set('service-{service_id}-templates')
def get_service_templates(self, service_id):
"""
Retrieve all templates for service.
@@ -293,8 +293,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
)
])
# @cache.delete('service-{service_id}-templates')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}-templates')
@cache.delete_by_pattern('service-{service_id}-template-*')
def delete_service_template(self, service_id, template_id):
"""
Set a service template's archived flag to True
@@ -322,7 +322,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
def get_guest_list(self, service_id):
return self.get(url='/service/{}/guest-list'.format(service_id))
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def update_guest_list(self, service_id, data):
return self.put(url='/service/{}/guest-list'.format(service_id), data=data)
@@ -358,7 +358,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
'/service/{}/inbound-sms/summary'.format(service_id)
)
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def create_service_inbound_api(self, service_id, url, bearer_token, user_id):
data = {
"url": url,
@@ -367,7 +367,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
}
return self.post("/service/{}/inbound-api".format(service_id), data)
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def update_service_inbound_api(self, service_id, url, bearer_token, user_id, inbound_api_id):
data = {
"url": url,
@@ -384,7 +384,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
)
)['data']
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def delete_service_inbound_api(self, service_id, callback_api_id):
return self.delete("/service/{}/inbound-api/{}".format(
service_id, callback_api_id
@@ -411,8 +411,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
data={"email": email_address}
)
# @cache.delete('service-{service_id}')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete_by_pattern('service-{service_id}-template-*')
def add_reply_to_email_address(self, service_id, email_address, is_default=False):
return self.post(
"/service/{}/email-reply-to".format(service_id),
@@ -422,8 +422,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
}
)
# @cache.delete('service-{service_id}')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete_by_pattern('service-{service_id}-template-*')
def update_reply_to_email_address(self, service_id, reply_to_email_id, email_address, is_default=False):
return self.post(
"/service/{}/email-reply-to/{}".format(
@@ -436,8 +436,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
}
)
# @cache.delete('service-{service_id}')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete_by_pattern('service-{service_id}-template-*')
def delete_reply_to_email_address(self, service_id, reply_to_email_id):
return self.post(
"/service/{}/email-reply-to/{}/archive".format(service_id, reply_to_email_id),
@@ -450,8 +450,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
def get_letter_contact(self, service_id, letter_contact_id):
return self.get("/service/{}/letter-contact/{}".format(service_id, letter_contact_id))
# @cache.delete('service-{service_id}')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete_by_pattern('service-{service_id}-template-*')
def add_letter_contact(self, service_id, contact_block, is_default=False):
return self.post(
"/service/{}/letter-contact".format(service_id),
@@ -461,8 +461,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
}
)
# @cache.delete('service-{service_id}')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete_by_pattern('service-{service_id}-template-*')
def update_letter_contact(self, service_id, letter_contact_id, contact_block, is_default=False):
return self.post(
"/service/{}/letter-contact/{}".format(
@@ -475,8 +475,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
}
)
# @cache.delete('service-{service_id}')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete_by_pattern('service-{service_id}-template-*')
def delete_letter_contact(self, service_id, letter_contact_id):
return self.post(
"/service/{}/letter-contact/{}/archive".format(service_id, letter_contact_id),
@@ -493,8 +493,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
"/service/{}/sms-sender/{}".format(service_id, sms_sender_id)
)
# @cache.delete('service-{service_id}')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete_by_pattern('service-{service_id}-template-*')
def add_sms_sender(self, service_id, sms_sender, is_default=False, inbound_number_id=None):
data = {
"sms_sender": sms_sender,
@@ -504,8 +504,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
data["inbound_number_id"] = inbound_number_id
return self.post("/service/{}/sms-sender".format(service_id), data=data)
# @cache.delete('service-{service_id}')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete_by_pattern('service-{service_id}-template-*')
def update_sms_sender(self, service_id, sms_sender_id, sms_sender, is_default=False):
return self.post(
"/service/{}/sms-sender/{}".format(service_id, sms_sender_id),
@@ -515,8 +515,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
}
)
# @cache.delete('service-{service_id}')
# @cache.delete_by_pattern('service-{service_id}-template-*')
@cache.delete('service-{service_id}')
@cache.delete_by_pattern('service-{service_id}-template-*')
def delete_sms_sender(self, service_id, sms_sender_id):
return self.post(
"/service/{}/sms-sender/{}/archive".format(service_id, sms_sender_id),
@@ -530,7 +530,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
)
)['data']
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def update_service_callback_api(self, service_id, url, bearer_token, user_id, callback_api_id):
data = {
"url": url,
@@ -540,13 +540,13 @@ class ServiceAPIClient(NotifyAdminAPIClient):
data['bearer_token'] = bearer_token
return self.post("/service/{}/delivery-receipt-api/{}".format(service_id, callback_api_id), data)
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def delete_service_callback_api(self, service_id, callback_api_id):
return self.delete("/service/{}/delivery-receipt-api/{}".format(
service_id, callback_api_id
))
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def create_service_callback_api(self, service_id, url, bearer_token, user_id):
data = {
"url": url,
@@ -555,7 +555,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
}
return self.post("/service/{}/delivery-receipt-api".format(service_id), data)
# @cache.delete('service-{service_id}-data-retention')
@cache.delete('service-{service_id}-data-retention')
def create_service_data_retention(self, service_id, notification_type, days_of_retention):
data = {
"notification_type": notification_type,
@@ -564,29 +564,29 @@ class ServiceAPIClient(NotifyAdminAPIClient):
return self.post("/service/{}/data-retention".format(service_id), data)
# @cache.delete('service-{service_id}-data-retention')
@cache.delete('service-{service_id}-data-retention')
def update_service_data_retention(self, service_id, data_retention_id, days_of_retention):
data = {
"days_of_retention": days_of_retention
}
return self.post("/service/{}/data-retention/{}".format(service_id, data_retention_id), data)
# @cache.set('service-{service_id}-data-retention')
@cache.set('service-{service_id}-data-retention')
def get_service_data_retention(self, service_id):
return self.get("/service/{}/data-retention".format(service_id))
# @cache.set('service-{service_id}-returned-letters-statistics')
@cache.set('service-{service_id}-returned-letters-statistics')
def get_returned_letter_statistics(self, service_id):
return self.get("service/{}/returned-letter-statistics".format(service_id))
# @cache.set('service-{service_id}-returned-letters-summary')
@cache.set('service-{service_id}-returned-letters-summary')
def get_returned_letter_summary(self, service_id):
return self.get("service/{}/returned-letter-summary".format(service_id))
def get_returned_letters(self, service_id, reported_at):
return self.get("service/{}/returned-letters?reported_at={}".format(service_id, reported_at))
# @cache.delete('service-{service_id}')
@cache.delete('service-{service_id}')
def set_service_broadcast_settings(
self, service_id, service_mode, broadcast_channel, provider_restriction, cached_service_user_ids
):

View File

@@ -6,7 +6,7 @@ class StatusApiClient(NotifyAdminAPIClient):
def get_status(self, *params):
return self.get(url='/_status', *params)
# @cache.set('live-service-and-organisation-counts', ttl_in_seconds=3600)
@cache.set('live-service-and-organisation-counts', ttl_in_seconds=3600)
def get_count_of_live_services_and_organisations(self):
return self.get(url='/_status/live-service-and-organisation-counts')

View File

@@ -1,10 +1,10 @@
from app.extensions import redis_client
from app.notify_client import NotifyAdminAPIClient
from app.notify_client import NotifyAdminAPIClient, cache
class TemplateFolderAPIClient(NotifyAdminAPIClient):
# @cache.delete('service-{service_id}-template-folders')
@cache.delete('service-{service_id}-template-folders')
def create_template_folder(
self,
service_id,
@@ -17,7 +17,7 @@ class TemplateFolderAPIClient(NotifyAdminAPIClient):
}
return self.post('/service/{}/template-folder'.format(service_id), data)['data']['id']
# @cache.set('service-{service_id}-template-folders')
@cache.set('service-{service_id}-template-folders')
def get_template_folders(self, service_id):
return self.get('/service/{}/template-folder'.format(service_id))['template_folders']
@@ -34,8 +34,8 @@ class TemplateFolderAPIClient(NotifyAdminAPIClient):
if folder['id'] == str(folder_id)
)
# @cache.delete('service-{service_id}-template-folders')
# @cache.delete('service-{service_id}-templates')
@cache.delete('service-{service_id}-template-folders')
@cache.delete('service-{service_id}-templates')
def move_to_folder(self, service_id, folder_id, template_ids, folder_ids):
if folder_id:
@@ -51,7 +51,7 @@ class TemplateFolderAPIClient(NotifyAdminAPIClient):
if template_ids:
redis_client.delete(*(f'service-{service_id}-template-{id}-version-None' for id in template_ids))
# @cache.delete('service-{service_id}-template-folders')
@cache.delete('service-{service_id}-template-folders')
def update_template_folder(self, service_id, template_folder_id, name, users_with_permission=None):
data = {"name": name}
if users_with_permission:
@@ -61,7 +61,7 @@ class TemplateFolderAPIClient(NotifyAdminAPIClient):
data
)
# @cache.delete('service-{service_id}-template-folders')
@cache.delete('service-{service_id}-template-folders')
def delete_template_folder(self, service_id, template_folder_id):
self.delete('/service/{}/template-folder/{}'.format(service_id, template_folder_id), {})

View File

@@ -1,6 +1,6 @@
from notifications_python_client.errors import HTTPError
from app.notify_client import NotifyAdminAPIClient
from app.notify_client import NotifyAdminAPIClient, cache
from app.utils.user_permissions import translate_permissions_from_ui_to_db
ALLOWED_ATTRIBUTES = {
@@ -34,7 +34,7 @@ class UserApiClient(NotifyAdminAPIClient):
def get_user(self, user_id):
return self._get_user(user_id)['data']
# @cache.set('user-{user_id}')
@cache.set('user-{user_id}')
def _get_user(self, user_id):
return self.get("/user/{}".format(user_id))
@@ -50,7 +50,7 @@ class UserApiClient(NotifyAdminAPIClient):
return None
raise e
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def update_user_attribute(self, user_id, **kwargs):
data = dict(kwargs)
disallowed_attributes = set(data.keys()) - ALLOWED_ATTRIBUTES
@@ -63,24 +63,24 @@ class UserApiClient(NotifyAdminAPIClient):
user_data = self.post(url, data=data)
return user_data['data']
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def archive_user(self, user_id):
return self.post('/user/{}/archive'.format(user_id), data=None)
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def reset_failed_login_count(self, user_id):
url = "/user/{}/reset-failed-login-count".format(user_id)
user_data = self.post(url, data={})
return user_data['data']
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def update_password(self, user_id, password):
data = {"_password": password}
url = "/user/{}/update-password".format(user_id)
user_data = self.post(url, data=data)
return user_data['data']
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def verify_password(self, user_id, password):
try:
url = "/user/{}/verify/password".format(user_id)
@@ -113,7 +113,7 @@ class UserApiClient(NotifyAdminAPIClient):
endpoint = '/user/{0}/email-already-registered'.format(user_id)
self.post(endpoint, data=data)
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def check_verify_code(self, user_id, code, code_type):
data = {'code_type': code_type, 'code': code}
endpoint = '/user/{}/verify/code'.format(user_id)
@@ -125,7 +125,7 @@ class UserApiClient(NotifyAdminAPIClient):
return False, e.message
raise e
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def complete_webauthn_login_attempt(self, user_id, is_successful):
data = {'successful': is_successful}
endpoint = f'/user/{user_id}/complete/webauthn-login'
@@ -145,9 +145,9 @@ class UserApiClient(NotifyAdminAPIClient):
endpoint = '/organisations/{}/users'.format(org_id)
return self.get(endpoint)['data']
# @cache.delete('service-{service_id}')
# @cache.delete('service-{service_id}-template-folders')
# @cache.delete('user-{user_id}')
@cache.delete('service-{service_id}')
@cache.delete('service-{service_id}-template-folders')
@cache.delete('user-{user_id}')
def add_user_to_service(self, service_id, user_id, permissions, folder_permissions):
# permissions passed in are the combined UI permissions, not DB permissions
endpoint = '/service/{}/users/{}'.format(service_id, user_id)
@@ -158,13 +158,13 @@ class UserApiClient(NotifyAdminAPIClient):
self.post(endpoint, data=data)
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def add_user_to_organisation(self, org_id, user_id):
resp = self.post('/organisations/{}/users/{}'.format(org_id, user_id), data={})
return resp['data']
# @cache.delete('service-{service_id}-template-folders')
# @cache.delete('user-{user_id}')
@cache.delete('service-{service_id}-template-folders')
@cache.delete('user-{user_id}')
def set_user_permissions(self, user_id, service_id, permissions, folder_permissions=None):
# permissions passed in are the combined UI permissions, not DB permissions
data = {
@@ -193,7 +193,7 @@ class UserApiClient(NotifyAdminAPIClient):
users = self.post(endpoint, data=data)
return users
# @cache.delete('user-{user_id}')
@cache.delete('user-{user_id}')
def activate_user(self, user_id):
return self.post("/user/{}/activate".format(user_id), data=None)

View File

@@ -105,7 +105,7 @@ def mock_get_service_settings_page_common(
'Count in list of live services Yes Change if service is counted in list of live services',
'Billing details None Change billing details for service',
'Notes None Change the notes for the service',
'Organisation Test organisation Central government Change organisation for service',
'Organisation Test Organisation Central government Change organisation for service',
'Rate limit 3,000 per minute Change rate limit',
'Message limit 1,000 per day Change daily message limit',
'Free text message allowance 250,000 per year Change free text message allowance',
@@ -288,7 +288,7 @@ def test_organisation_name_links_to_org_dashboard(
org_row = find_element_by_tag_and_partial_text(response, tag='tr', string='Organisation')
assert org_row.find('a')['href'] == url_for('main.organisation_dashboard', org_id=ORGANISATION_ID)
assert normalize_spaces(org_row.find('a').text) == 'Test organisation'
assert normalize_spaces(org_row.find('a').text) == 'Test Organisation'
@pytest.mark.parametrize('service_contact_link,expected_text', [

View File

@@ -833,7 +833,7 @@ def test_should_show_upcoming_jobs_on_dashboard(
'main.service_dashboard',
service_id=SERVICE_ONE_ID,
)
mock_get_jobs.assert_called_once_with(SERVICE_ONE_ID)
mock_get_scheduled_job_stats.assert_called_once_with(SERVICE_ONE_ID)
assert normalize_spaces(

View File

@@ -131,7 +131,7 @@ def test_should_return_200_when_email_is_not_gov_uk(
@pytest.mark.parametrize('email_address', (
'notfound@example.gsa.gov',
'example@lsquo.net',
pytest.param('example@lsquo.net', marks=pytest.mark.xfail(raises=AssertionError)),
pytest.param('example@ellipsis.com', marks=pytest.mark.xfail(raises=AssertionError)),
))
def test_should_add_user_details_to_session(
@@ -151,9 +151,9 @@ def test_should_add_user_details_to_session(
_data={
'name': 'Test Codes',
'email_address': email_address,
'mobile_number': '+4407700900460',
'mobile_number': '+17733541500',
'password': 'validPassword!'
},
}
)
with client_request.session_transaction() as session:
assert session['user_details']['email'] == email_address

View File

@@ -26,7 +26,6 @@ def test_organisation_type_when_service_and_its_org_both_have_an_org_type(mocker
assert service.organisation_type == 'local'
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_organisation_name_comes_from_cache(mocker, service_one):
mock_redis_get = mocker.patch(
'app.extensions.RedisClient.get',
@@ -41,7 +40,6 @@ def test_organisation_name_comes_from_cache(mocker, service_one):
assert mock_get_organisation.called is False
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_organisation_name_goes_into_cache(mocker, service_one):
mocker.patch(
'app.extensions.RedisClient.get',
@@ -65,7 +63,6 @@ def test_organisation_name_goes_into_cache(mocker, service_one):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_service_without_organisation_doesnt_need_org_api(mocker, service_one):
mock_redis_get = mocker.patch('app.extensions.RedisClient.get')
mock_get_organisation = mocker.patch('app.organisations_client.get_organisation')

View File

@@ -1,5 +1,3 @@
import pytest
from app.notify_client.broadcast_message_api_client import (
BroadcastMessageAPIClient,
)
@@ -39,7 +37,6 @@ def test_get_broadcast_messages(mocker):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_get_broadcast_message(mocker):
client = BroadcastMessageAPIClient()
mocker.patch('app.notify_client.current_user', id='1')
@@ -59,7 +56,6 @@ def test_get_broadcast_message(mocker):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_update_broadcast_message(mocker):
client = BroadcastMessageAPIClient()
mocker.patch('app.notify_client.current_user', id='1')
@@ -79,7 +75,6 @@ def test_update_broadcast_message(mocker):
mock_redis_delete.assert_called_once_with('service-12345-broadcast-message-67890')
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_update_broadcast_message_status(mocker):
client = BroadcastMessageAPIClient()
mocker.patch('app.notify_client.current_user', id='1')

View File

@@ -1,11 +1,8 @@
from unittest.mock import call
import pytest
from app.notify_client.email_branding_client import EmailBrandingClient
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_get_email_branding(mocker, fake_uuid):
mock_get = mocker.patch(
'app.notify_client.email_branding_client.EmailBrandingClient.get',
@@ -30,7 +27,6 @@ def test_get_email_branding(mocker, fake_uuid):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_get_all_email_branding(mocker):
mock_get = mocker.patch(
'app.notify_client.email_branding_client.EmailBrandingClient.get',
@@ -55,7 +51,6 @@ def test_get_all_email_branding(mocker):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_create_email_branding(mocker):
org_data = {'logo': 'test.png', 'name': 'test name', 'text': 'test name', 'colour': 'red',
'brand_type': 'org'}
@@ -75,7 +70,6 @@ def test_create_email_branding(mocker):
mock_redis_delete.assert_called_once_with('email_branding')
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_update_email_branding(mocker, fake_uuid):
org_data = {'logo': 'test.png', 'name': 'test name', 'text': 'test name', 'colour': 'red',
'brand_type': 'org'}

View File

@@ -7,7 +7,6 @@ from app.models.job import Job, PaginatedJobs
from app.notify_client.job_api_client import JobApiClient
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_client_creates_job_data_correctly(mocker, fake_uuid):
job_id = fake_uuid
service_id = fake_uuid
@@ -333,7 +332,6 @@ def test_cancel_job(mocker):
'false',
),
])
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_has_jobs_sets_cache(
mocker,
fake_uuid,
@@ -363,7 +361,6 @@ def test_has_jobs_sets_cache(
(b'true', True),
(b'false', False),
])
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_has_jobs_returns_from_cache(
mocker,
fake_uuid,

View File

@@ -1,11 +1,8 @@
from unittest.mock import call
import pytest
from app.notify_client.letter_branding_client import LetterBrandingClient
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_get_letter_branding(mocker, fake_uuid):
mock_get = mocker.patch(
'app.notify_client.letter_branding_client.LetterBrandingClient.get',
@@ -25,7 +22,6 @@ def test_get_letter_branding(mocker, fake_uuid):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_get_all_letter_branding(mocker):
mock_get = mocker.patch('app.notify_client.letter_branding_client.LetterBrandingClient.get', return_value=[1, 2, 3])
mock_redis_get = mocker.patch('app.extensions.RedisClient.get', return_value=None)
@@ -42,7 +38,6 @@ def test_get_all_letter_branding(mocker):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_create_letter_branding(mocker):
new_branding = {'filename': 'uuid-test', 'name': 'my letters'}
@@ -60,7 +55,6 @@ def test_create_letter_branding(mocker):
mock_redis_delete.assert_called_once_with('letter_branding')
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_update_letter_branding(mocker, fake_uuid):
branding = {'filename': 'uuid-test', 'name': 'my letters'}

View File

@@ -92,7 +92,6 @@ from app import organisations_client
),
]
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_returns_value_from_cache(
notify_admin,
mocker,
@@ -125,7 +124,6 @@ def test_returns_value_from_cache(
assert mock_redis_set.call_args_list == expected_cache_set_calls
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_deletes_domain_cache(
notify_admin,
mock_get_user,
@@ -153,7 +151,6 @@ def test_deletes_domain_cache(
call('domains'),
]),
))
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_update_organisation_when_not_updating_org_type(
mocker,
fake_uuid,
@@ -173,7 +170,6 @@ def test_update_organisation_when_not_updating_org_type(
assert mock_redis_delete.call_args_list == expected_cache_delete_calls
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_update_organisation_when_updating_org_type_and_org_has_services(mocker, fake_uuid):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post')
@@ -195,7 +191,6 @@ def test_update_organisation_when_updating_org_type_and_org_has_services(mocker,
]
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_update_organisation_when_updating_org_type_but_org_has_no_services(mocker, fake_uuid):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post')
@@ -216,7 +211,6 @@ def test_update_organisation_when_updating_org_type_but_org_has_no_services(mock
]
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_update_service_organisation_deletes_cache(mocker, fake_uuid):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post')
@@ -237,7 +231,6 @@ def test_update_service_organisation_deletes_cache(mocker, fake_uuid):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_remove_user_from_organisation_deletes_user_cache(mocker):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_delete = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.delete')

View File

@@ -1,13 +1,10 @@
from datetime import date
import pytest
from app.notify_client.performance_dashboard_api_client import (
PerformanceDashboardAPIClient,
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_get_aggregate_platform_stats(mocker):
mocker.patch('app.extensions.RedisClient.get', return_value=None)
client = PerformanceDashboardAPIClient()
@@ -24,7 +21,6 @@ def test_get_aggregate_platform_stats(mocker):
})
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_sets_value_in_cache(mocker):
client = PerformanceDashboardAPIClient()
@@ -56,7 +52,6 @@ def test_sets_value_in_cache(mocker):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_returns_value_from_cache(mocker):
client = PerformanceDashboardAPIClient()

View File

@@ -10,7 +10,6 @@ from tests.conftest import SERVICE_ONE_ID
FAKE_TEMPLATE_ID = uuid4()
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_client_posts_archived_true_when_deleting_template(mocker):
mocker.patch('app.notify_client.current_user', id='1')
mock_redis_delete_by_pattern = mocker.patch('app.extensions.RedisClient.delete_by_pattern')
@@ -354,7 +353,6 @@ def test_client_returns_count_of_service_templates(
),
]
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_returns_value_from_cache(
mocker,
client_method,
@@ -410,7 +408,6 @@ def test_returns_value_from_cache(
(user_api_client, 'add_user_to_service', [SERVICE_ONE_ID, uuid4(), [], []], {}),
(invite_api_client, 'accept_invite', [SERVICE_ONE_ID, uuid4()], {}),
])
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_deletes_service_cache(
notify_admin,
mock_get_user,
@@ -455,7 +452,6 @@ def test_deletes_service_cache(
'service-{}'.format(SERVICE_ONE_ID),
]),
])
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_deletes_caches_when_modifying_templates(
notify_admin,
mock_get_user,
@@ -479,7 +475,6 @@ def test_deletes_caches_when_modifying_templates(
assert mock_redis_delete_by_pattern.call_args_list[0] == call(f'service-{SERVICE_ONE_ID}-template-*')
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_deletes_cached_users_when_archiving_service(mocker, mock_get_service_templates):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_redis_delete_by_pattern = mocker.patch('app.extensions.RedisClient.delete_by_pattern')
@@ -492,7 +487,6 @@ def test_deletes_cached_users_when_archiving_service(mocker, mock_get_service_te
assert call(f'service-{SERVICE_ONE_ID}-template-*') in mock_redis_delete_by_pattern.call_args_list
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_deletes_cached_users_when_changing_broadcast_service_settings(mocker):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
@@ -534,7 +528,6 @@ def test_client_updates_guest_list(mocker):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_client_doesnt_delete_service_template_cache_when_none_exist(
notify_admin,
mock_get_user,
@@ -554,7 +547,6 @@ def test_client_doesnt_delete_service_template_cache_when_none_exist(
assert len(mock_redis_delete_by_pattern.call_args_list) == 1
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_client_deletes_service_template_cache_when_service_is_updated(
notify_admin,
mock_get_user,

View File

@@ -1,9 +1,6 @@
import pytest
from app.notify_client.status_api_client import StatusApiClient
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_get_count_of_live_services_and_organisations(mocker):
mocker.patch('app.extensions.RedisClient.get', return_value=None)
client = StatusApiClient()
@@ -14,7 +11,6 @@ def test_get_count_of_live_services_and_organisations(mocker):
mock.assert_called_once_with(url='/_status/live-service-and-organisation-counts')
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_sets_value_in_cache(mocker):
client = StatusApiClient()
@@ -41,7 +37,6 @@ def test_sets_value_in_cache(mocker):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_returns_value_from_cache(mocker):
client = StatusApiClient()

View File

@@ -8,7 +8,6 @@ from app.notify_client.template_folder_api_client import TemplateFolderAPIClient
@pytest.mark.parametrize('parent_id', [uuid.uuid4(), None])
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_create_template_folder_calls_correct_api_endpoint(mocker, parent_id):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
@@ -26,7 +25,6 @@ def test_create_template_folder_calls_correct_api_endpoint(mocker, parent_id):
mock_redis_delete.assert_called_once_with('service-{}-template-folders'.format(some_service_id))
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_get_template_folders_calls_correct_api_endpoint(mocker):
mock_redis_get = mocker.patch('app.extensions.RedisClient.get', return_value=None)
mock_redis_set = mocker.patch('app.extensions.RedisClient.set')
@@ -50,7 +48,6 @@ def test_get_template_folders_calls_correct_api_endpoint(mocker):
mock_redis_set.assert_called_once_with(redis_key, '{"a": "b"}', ex=604800)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_move_templates_and_folders(mocker):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
@@ -108,7 +105,6 @@ def test_move_templates_and_folders_to_root(mocker):
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_update_template_folder_calls_correct_api_endpoint(mocker):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
@@ -127,7 +123,6 @@ def test_update_template_folder_calls_correct_api_endpoint(mocker):
mock_redis_delete.assert_called_once_with('service-{}-template-folders'.format(some_service_id))
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_delete_template_folder_calls_correct_api_endpoint(mocker):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')

View File

@@ -155,7 +155,6 @@ def test_client_converts_admin_permissions_to_db_permissions_on_add_to_service(n
),
]
)
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_returns_value_from_cache(
notify_admin,
mocker,
@@ -203,7 +202,6 @@ def test_returns_value_from_cache(
(service_api_client, 'create_service', ['', '', 0, False, user_id, sample_uuid()], {}),
(invite_api_client, 'accept_invite', [SERVICE_ONE_ID, user_id], {}),
])
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_deletes_user_cache(
notify_admin,
mock_get_user,
@@ -223,7 +221,6 @@ def test_deletes_user_cache(
assert len(mock_request.call_args_list) == 1
@pytest.mark.skip(reason='@cache decorator disabled until caching is fixed')
def test_add_user_to_service_calls_correct_endpoint_and_deletes_keys_from_cache(mocker):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')

View File

@@ -11,7 +11,7 @@ def vcap_services():
return {
'aws-elasticache-redis': [{
'credentials': {
'uri': 'redis uri'
'uri': 'redis://xxx:6379'
}
}],
}
@@ -21,4 +21,4 @@ def test_extract_cloudfoundry_config_populates_other_vars(os_environ, vcap_servi
os.environ['VCAP_SERVICES'] = json.dumps(vcap_services)
extract_cloudfoundry_config()
assert os.environ['REDIS_URL'] == 'redis uri'
assert os.environ['REDIS_URL'] == 'rediss://xxx:6379'