Skip to content

Commit

Permalink
Merge pull request #199 from praekeltfoundation/dependabot/pip/pillow…
Browse files Browse the repository at this point in the history
…-10.2.0

Bump pillow from 9.3.0 to 10.2.0
  • Loading branch information
erikh360 authored Jan 29, 2024
2 parents bc48622 + 11ae726 commit 2bbf887
Show file tree
Hide file tree
Showing 28 changed files with 152 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qa_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7.15
python-version: 3.9
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y gdal-bin
Expand Down
2 changes: 1 addition & 1 deletion clinicfinder/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class LocationSerializer(GeoModelSerializer):
""" A class to serialize locations"""
"""A class to serialize locations"""

longitude = serializers.FloatField(required=True)
latitude = serializers.FloatField(required=True)
Expand Down
4 changes: 2 additions & 2 deletions clinicfinder/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ClinicFinderViewTests(APITestCase):
@override_settings(LOCATION_SEARCH_RADIUS=100)
def test_clinic_finder_list(self):
"""
Returns a list of the nearest clinics
Returns a list of the nearest clinics
"""
user = get_user_model().objects.create_user("test")
user.user_permissions.add(Permission.objects.get(codename="add_covid19triage"))
Expand All @@ -25,7 +25,7 @@ def test_clinic_finder_list(self):

def test_clinic_finder_error(self):
"""
Returns an error if longitude or latitude is not provided
Returns an error if longitude or latitude is not provided
"""
user = get_user_model().objects.create_user("test")
user.user_permissions.add(Permission.objects.get(codename="add_covid19triage"))
Expand Down
6 changes: 5 additions & 1 deletion clinicfinder/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
app_name = "clinicfinder"

urlpatterns = [
path("clinic_finder/", ClinicFinderView.as_view(), name="clinic_finder",),
path(
"clinic_finder/",
ClinicFinderView.as_view(),
name="clinic_finder",
),
]
5 changes: 4 additions & 1 deletion contacts/migrations/0002_auto_20200721_1306.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RemoveField(model_name="contact", name="cases",),
migrations.RemoveField(
model_name="contact",
name="cases",
),
migrations.AddField(
model_name="case",
name="contact",
Expand Down
15 changes: 12 additions & 3 deletions contacts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,27 @@ def up_for_notification(self):

class Case(ExportModelOperationsMixin("case"), models.Model):
external_id = models.CharField(
max_length=255, blank=False, default=get_uuid, unique=True,
max_length=255,
blank=False,
default=get_uuid,
unique=True,
)
date_start = models.DateTimeField(null=False, auto_now_add=False)
date_notification_start = models.DateTimeField(null=True, auto_now_add=False)
date_notification_end = models.DateTimeField(null=True, auto_now_add=False)
case_id = models.CharField(blank=True, null=True, max_length=50)
name = models.CharField(blank=True, null=True, max_length=30)
created_by = models.ForeignKey(
User, related_name="cases", on_delete=models.SET_NULL, null=True,
User,
related_name="cases",
on_delete=models.SET_NULL,
null=True,
)
contact = models.ForeignKey(
Contact, null=True, related_name="cases", on_delete=models.SET_NULL,
Contact,
null=True,
related_name="cases",
on_delete=models.SET_NULL,
)
created_at = models.DateTimeField(auto_now_add=True)
is_active = models.BooleanField(default=True)
Expand Down
4 changes: 3 additions & 1 deletion contacts/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def send_contact_update(phone_number, confirmed_contact, case_id):
# case started
case.date_notification_start = timezone.now()
case.save(
update_fields=["date_notification_start",] # noqa: E231 E126 E261
update_fields=[
"date_notification_start",
] # noqa: E231 E126 E261
)
else:
# case ended
Expand Down
6 changes: 4 additions & 2 deletions contacts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ def setUp(self):
self.client = Client()

admin = User.objects.create_superuser(
username="testadmin", password="testadminpassword",
username="testadmin",
password="testadminpassword",
)

logger.info("Created superuser")

self.client.login(
username="testadmin", password="testadminpassword",
username="testadmin",
password="testadminpassword",
)

logger.info("Logged in with superuser")
Expand Down
4 changes: 3 additions & 1 deletion covid_cases/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ class ScrapeSACoronavirusHomepageTests(APITestCase):
def test_scrape_sacoronavirus_hompage(self):
with gzip.open("covid_cases/mock_data/sacoronavirus.txt.gz") as f:
responses.add(
method="GET", url="https://sacoronavirus.co.za", body=f.read(),
method="GET",
url="https://sacoronavirus.co.za",
body=f.read(),
)
result = scrape_sacoronavirus_homepage()
self.assertIn("tests=19988045", result)
Expand Down
8 changes: 6 additions & 2 deletions healthcheck/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
def get_bigquery_client(key_path):
if os.path.isfile(key_path):
credentials = service_account.Credentials.from_service_account_file(
key_path, scopes=["https://www.googleapis.com/auth/cloud-platform"],
key_path,
scopes=["https://www.googleapis.com/auth/cloud-platform"],
)

return bigquery.Client(credentials=credentials, project=credentials.project_id,)
return bigquery.Client(
credentials=credentials,
project=credentials.project_id,
)


def get_latest_bigquery_timestamp(bigquery_client, dataset, model, field):
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
isort==4.3.21
black==19.10b0
flake8==3.8.1
isort==5.13.2
black==24.1.1
flake8==7.0.0
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pathspec==0.8.0
pathtools==0.1.2
phonenumbers==8.12.6
prometheus-client==0.8.0
psycopg2==2.8.5
psycopg2==2.9.9
pycodestyle==2.6.0
pycountry==20.7.3
pyflakes==2.2.0
Expand All @@ -59,7 +59,7 @@ opencv-python-headless==4.5.2.54
zbar-py==1.0.4
drf-spectacular==0.20.2
beautifulsoup4==4.10.0
Pillow==9.3.0
Pillow==10.2.0
django-storages==1.12.3
boto3==1.20.24
django-celery-results==2.4.0
Expand Down
6 changes: 4 additions & 2 deletions selfswab/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def test_is_barcode_format_valid(self):
class UploadTurnMediaTests(TestCase):
@responses.activate
@override_settings(
SELFSWAB_TURN_URL="https://turn.io", SELFSWAB_TURN_TOKEN="321",
SELFSWAB_TURN_URL="https://turn.io",
SELFSWAB_TURN_TOKEN="321",
)
def test_upload_turn_media(self):

Expand All @@ -59,7 +60,8 @@ def test_upload_turn_media(self):
class SendWhatsAppMediaTests(TestCase):
@responses.activate
@override_settings(
SELFSWAB_TURN_URL="https://turn.io", SELFSWAB_TURN_TOKEN="321",
SELFSWAB_TURN_URL="https://turn.io",
SELFSWAB_TURN_TOKEN="321",
)
def test_send_whatsapp_media_message(self):
responses.add(
Expand Down
30 changes: 24 additions & 6 deletions selfswab/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ def test_rapidpro_not_configured(self):

@responses.activate
@override_settings(
RAPIDPRO_URL="https://rp-test.com", SELFSWAB_RAPIDPRO_TOKEN="123",
RAPIDPRO_URL="https://rp-test.com",
SELFSWAB_RAPIDPRO_TOKEN="123",
)
def test_contact_not_found(self):
user = get_user_model().objects.create_user("test")
Expand Down Expand Up @@ -401,7 +402,8 @@ def test_contact_not_found(self):

@responses.activate
@override_settings(
RAPIDPRO_URL="https://rp-test.com", SELFSWAB_RAPIDPRO_TOKEN="123",
RAPIDPRO_URL="https://rp-test.com",
SELFSWAB_RAPIDPRO_TOKEN="123",
)
def test_contact_exists_not_in_group(self):
user = get_user_model().objects.create_user("test")
Expand Down Expand Up @@ -514,7 +516,8 @@ def test_contact_exists_not_in_group(self):

@responses.activate
@override_settings(
RAPIDPRO_URL="https://rp-test.com", SELFSWAB_RAPIDPRO_TOKEN="123",
RAPIDPRO_URL="https://rp-test.com",
SELFSWAB_RAPIDPRO_TOKEN="123",
)
def test_contact_exists_in_group(self):
user = get_user_model().objects.create_user("test")
Expand Down Expand Up @@ -597,15 +600,25 @@ class SendTestResultPDFViewViewSetTests(APITestCase):
def test_unautorized(self):
user = get_user_model().objects.create_user("test")

response = self.client.post(self.url, {"barcode": "CP123",},)
response = self.client.post(
self.url,
{
"barcode": "CP123",
},
)

self.assertEqual(response.status_code, 401)

def test_barcode_not_found(self):
user = get_user_model().objects.create_user("test")
self.client.force_authenticate(user)

response = self.client.post(self.url, {"barcode": "CP123",},)
response = self.client.post(
self.url,
{
"barcode": "CP123",
},
)

self.assertEqual(response.status_code, 404)

Expand All @@ -623,7 +636,12 @@ def test_send_result_pdf(self, mock_send_whatsapp_media_message):
}
)

response = self.client.post(self.url, {"barcode": "CP159600001",},)
response = self.client.post(
self.url,
{
"barcode": "CP159600001",
},
)

self.assertEqual(response.status_code, 200)

Expand Down
4 changes: 3 additions & 1 deletion selfswab/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def upload_turn_media(media, content_type="application/pdf"):
}

response = requests.post(
urljoin(settings.SELFSWAB_TURN_URL, f"v1/media"), headers=headers, data=media,
urljoin(settings.SELFSWAB_TURN_URL, f"v1/media"),
headers=headers,
data=media,
)
response.raise_for_status()
return response.json()["media"][0]["id"]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

requirements = [
"django-environ==0.4.5",
"psycopg2==2.8.5",
"psycopg2==2.9.9",
"requests==2.31.0",
"rapidpro-python==2.6.1",
"django-import-export==2.5.0",
Expand Down
4 changes: 3 additions & 1 deletion tbconnect/migrations/0006_auto_20200908_1655.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class Migration(migrations.Migration):

operations = [
migrations.AlterField(
model_name="tbcheck", name="cough", field=models.BooleanField(),
model_name="tbcheck",
name="cough",
field=models.BooleanField(),
),
migrations.AlterField(
model_name="tbcheck",
Expand Down
5 changes: 4 additions & 1 deletion tbconnect/migrations/0011_remove_tbcheck_group_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RemoveField(model_name="tbcheck", name="group_arm",),
migrations.RemoveField(
model_name="tbcheck",
name="group_arm",
),
]
6 changes: 4 additions & 2 deletions tbconnect/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def perform_sync_to_rapidpro():

tbconnect_group_arm_timestamp = None
if contact.tbconnect_group_arm_timestamp:
tbconnect_group_arm_timestamp = contact.tbconnect_group_arm_timestamp.strftime(
"%Y-%m-%dT%H:%M:%SZ"
tbconnect_group_arm_timestamp = (
contact.tbconnect_group_arm_timestamp.strftime(
"%Y-%m-%dT%H:%M:%SZ"
)
)
rapidpro.create_flow_start(
urns=[urn],
Expand Down
25 changes: 18 additions & 7 deletions tbconnect/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,9 @@ def test_valid_tbcheck(self):
class TBResetViewSetTests(APITestCase):
url = reverse("tbreset-detail", args=("+27856454612",))

@override_settings(ALLOW_TB_RESET_MSISDNS=["+27820010001"],)
@override_settings(
ALLOW_TB_RESET_MSISDNS=["+27820010001"],
)
def test_reset_not_allowed(self):
"""
The supplied msisdn is not reset when not allowed.
Expand All @@ -544,7 +546,9 @@ def test_reset_not_allowed(self):
response = self.client.get(self.url)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

@override_settings(ALLOW_TB_RESET_MSISDNS=["+27856454612"],)
@override_settings(
ALLOW_TB_RESET_MSISDNS=["+27856454612"],
)
def test_reset_allowed(self):
"""
The whitelisted msisdn is allowed to be reset.
Expand Down Expand Up @@ -644,10 +648,13 @@ def test_activation_active(self):
response = self.client.post(self.url, {"activation": "tb_study_a"})
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
response.json(), {"is_activation_active": False},
response.json(),
{"is_activation_active": False},
)

@override_settings(TB_STUDY_A_END_DATE="2023-10-16",)
@override_settings(
TB_STUDY_A_END_DATE="2023-10-16",
)
def test_activation_inactive_out_of_date(self):
"""
If we've reached the end date, return False
Expand All @@ -658,10 +665,13 @@ def test_activation_inactive_out_of_date(self):
response = self.client.post(self.url, {"activation": "tb_study_a"})
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
response.json(), {"is_activation_active": False},
response.json(),
{"is_activation_active": False},
)

@override_settings(TB_STUDY_A_MAX_COUNT=1,)
@override_settings(
TB_STUDY_A_MAX_COUNT=1,
)
def test_activation_inactive_max_count(self):
"""
If we've reached the max count, return False
Expand All @@ -675,5 +685,6 @@ def test_activation_inactive_max_count(self):
response = self.client.post(self.url, {"activation": "tb_study_a"})
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
response.json(), {"is_activation_active": False},
response.json(),
{"is_activation_active": False},
)
Loading

0 comments on commit 2bbf887

Please sign in to comment.