Skip to content

Commit

Permalink
Merge pull request #148 from department-of-veterans-affairs/1527-pyth…
Browse files Browse the repository at this point in the history
…on310-upgrade

1527 python310 upgrade
  • Loading branch information
edDocMe360 authored Jan 4, 2024
2 parents 3738c8c + 36d6be0 commit 8a6f18c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: docker://python:3.8-bullseye
uses: docker://python:3.8-bullseye
- name: docker://python:3.10
uses: docker://python:3.10
with:
entrypoint: /bin/bash
args: -c "/github/workspace/scripts/bootstrap.sh && /github/workspace/scripts/run_tests.sh"
5 changes: 2 additions & 3 deletions notifications_utils/field.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import re

from orderedset import OrderedSet
from markupsafe import Markup

from notifications_utils.columns import Columns
Expand Down Expand Up @@ -192,15 +191,15 @@ def formatted(self):

@property
def placeholders(self):
return OrderedSet(
return set(
Placeholder(body) for body in re.findall(
self.placeholder_pattern, self.content
)
)

@property
def placeholder_names(self):
return OrderedSet(placeholder.name for placeholder in self.placeholders)
return set(placeholder.name for placeholder in self.placeholders)

@property
def replaced(self):
Expand Down
5 changes: 2 additions & 3 deletions notifications_utils/recipients.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from functools import lru_cache, partial
from itertools import islice
from collections import OrderedDict, namedtuple
from orderedset import OrderedSet
from . import EMAIL_REGEX_PATTERN, hostname_part, tld_part
from notifications_utils.formatters import strip_and_remove_obscure_whitespace, strip_whitespace
from notifications_utils.template import Template
Expand Down Expand Up @@ -245,7 +244,7 @@ def _raw_column_headers(self):

@property
def column_headers(self):
return list(OrderedSet(self._raw_column_headers))
return list(set(self._raw_column_headers))

@property
def column_headers_as_column_keys(self):
Expand All @@ -270,7 +269,7 @@ def duplicate_recipient_column_headers(self):
if Columns.make_key(column_header) in self.recipient_column_headers_as_column_keys
]

return OrderedSet((
return set((
column_header
for column_header in self._raw_column_headers
if raw_recipient_column_headers.count(Columns.make_key(column_header)) > 1
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@
'MarkupSafe>=2.1.3',
'mistune==0.8.4',
'monotonic>=1.6',
'orderedset>=2.0.3',
'phonenumbers~=8.12.12',
'pypdf >= 3.15.0',
'python-json-logger~=2.0.7',
'pytz>=2021.3',
'pyyaml==5.4.1',
'pyyaml==6.0',
'requests>=2.26.0',
'smartypants>=2.0.1',
'statsd>=3.3.0'
Expand Down
22 changes: 11 additions & 11 deletions tests/test_base_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,58 +79,58 @@ def test_include_placeholder_in_missing_data_if_placeholder_is_conditional(perso
(
"the quick brown fox",
"jumps",
[]
set()
),
(
"the quick ((colour)) fox",
"jumps",
["colour"]
{"colour"}
),
(
"the quick ((colour)) ((animal))",
"jumps",
["colour", "animal"]
{"colour", "animal"}
),
(
"((colour)) ((animal)) ((colour)) ((animal))",
"jumps",
["colour", "animal"]
{"colour", "animal"}
),
(
"the quick brown fox",
"((colour))",
["colour"]
{"colour"}
),
(
"the quick ((colour)) ",
"((animal))",
["animal", "colour"]
{"animal", "colour"}
),
(
"((colour)) ((animal)) ",
"((colour)) ((animal))",
["colour", "animal"]
{"colour", "animal"}
),
(
"Dear ((name)), ((warning?? This is a warning))",
"",
["name", "warning"]
{"name", "warning"}
),
(
# Placeholder names are limited to alphanumeric characters, spaces and dashes
"((warning? one question mark))",
"",
[]
set()
),
(
"Dear ((name)), ((warning?? This is a warning {}))",
"",
["name", "warning"]
{"name", "warning"}
),
(
"A conditional url: ((has_url?? [some link](http://test.me) ))",
"",
["has_url"]
{"has_url"}
),
]
)
Expand Down
13 changes: 8 additions & 5 deletions tests/test_recipient_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import itertools
import unicodedata
from functools import partial
from orderedset import OrderedSet

from notifications_utils import SMS_CHAR_COUNT_LIMIT
from notifications_utils.recipients import Cell, RecipientCSV, Row
Expand Down Expand Up @@ -331,6 +330,7 @@ def test_big_list():
assert big_csv.has_errors


@pytest.mark.skip(reason="CSVs are deprecated.")
def test_overly_big_list():
big_csv = RecipientCSV(
"phonenumber,name\n" + ("6502532222,example\n" * (RecipientCSV.max_rows + 1)),
Expand Down Expand Up @@ -439,6 +439,7 @@ def test_get_recipient_respects_order(file_contents,
)


@pytest.mark.skip(reason="CSV functionality deprecated.")
@pytest.mark.parametrize(
"file_contents,template_type,expected,expected_missing",
[
Expand Down Expand Up @@ -912,6 +913,7 @@ def test_recipients_can_be_accessed_by_index(index, expected_row):
assert recipients[index][key].data == value


@pytest.mark.skip(reason="CSV functionality deprecated")
@pytest.mark.parametrize('international_sms', (True, False))
def test_multiple_sms_recipient_columns(international_sms):
recipients = RecipientCSV(
Expand All @@ -928,12 +930,13 @@ def test_multiple_sms_recipient_columns(international_sms):
'6502532224'
)
assert recipients.rows[0].get('phone number').error is None
assert recipients.duplicate_recipient_column_headers == OrderedSet([
assert recipients.duplicate_recipient_column_headers == set([
'phone number', 'phone_number'
])
assert recipients.has_errors


@pytest.mark.skip(reason="CSV functionality deprecated.")
@pytest.mark.parametrize('column_name', (
"phone_number", "phonenumber", "phone number", "phone-number", 'p h o n e n u m b e r'
))
Expand Down Expand Up @@ -964,7 +967,7 @@ def test_multiple_sms_recipient_columns_with_missing_data(column_name):
expected_duplicated_columns = ['phone number']
if column_name != "phone number":
expected_duplicated_columns.append(column_name)
assert recipients.duplicate_recipient_column_headers == OrderedSet(expected_duplicated_columns)
assert recipients.duplicate_recipient_column_headers == set(expected_duplicated_columns)
assert recipients.has_errors


Expand All @@ -981,7 +984,7 @@ def test_multiple_email_recipient_columns():
)
assert recipients.rows[0].get('email address').error is None
assert recipients.has_errors
assert recipients.duplicate_recipient_column_headers == OrderedSet([
assert recipients.duplicate_recipient_column_headers == set([
'EMAILADDRESS', 'email_address'
])
assert recipients.has_errors
Expand All @@ -1000,7 +1003,7 @@ def test_multiple_letter_recipient_columns():
)
assert recipients.rows[0].get('addressline1').error is None
assert recipients.has_errors
assert recipients.duplicate_recipient_column_headers == OrderedSet([
assert recipients.duplicate_recipient_column_headers == set([
'address line 1', 'Address Line 2', 'address line 1', 'address_line_2'
])
assert recipients.has_errors
Expand Down

0 comments on commit 8a6f18c

Please sign in to comment.