Skip to content

Commit 67ec692

Browse files
Feature/bcss 21324 subject creation util (#124)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Adding a new utility to allow for the creation of subjects. ## Context <!-- Why is this change required? What problem does it solve? --> This is needed as it is used in some selenium tests. If we want to migrate them across this logic is required. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [x] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent a60c8ae commit 67ec692

20 files changed

+2432
-12
lines changed

classes/address.py

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
import logging
2+
3+
4+
class Address:
5+
"""
6+
Represents a postal address with up to five address lines and a postcode.
7+
Provides methods to set individual lines and to format the address as a string.
8+
"""
9+
10+
def __init__(self) -> None:
11+
self.address_line1: str = ""
12+
self.address_line2: str = ""
13+
self.address_line3: str = ""
14+
self.address_line4: str = ""
15+
self.address_line5: str = ""
16+
self.post_code: str = ""
17+
18+
def set_address_line(self, line_number: int, address_line: str) -> None:
19+
"""
20+
Sets the specified address line (1-5) to the given value.
21+
22+
Args:
23+
line_number (int): The address line number (1-5).
24+
address_line (str): The value to set for the address line.
25+
26+
Raises:
27+
ValueError: If line_number is not between 1 and 5.
28+
"""
29+
logging.info(
30+
f"start: set_address_line(line_number={line_number}, address_line={address_line})"
31+
)
32+
if line_number == 1:
33+
self.address_line1 = address_line
34+
elif line_number == 2:
35+
self.address_line2 = address_line
36+
elif line_number == 3:
37+
self.address_line3 = address_line
38+
elif line_number == 4:
39+
self.address_line4 = address_line
40+
elif line_number == 5:
41+
self.address_line5 = address_line
42+
else:
43+
raise ValueError(
44+
f"Invalid line number {line_number}, must be between 1 and 5"
45+
)
46+
logging.info(
47+
f"end: set_address_line(line_number={line_number}, address_line={address_line})"
48+
)
49+
50+
def __str__(self) -> str:
51+
"""
52+
Returns the formatted address as a single string.
53+
"""
54+
address_parts = [
55+
self.address_line1,
56+
self.address_line2,
57+
self.address_line3,
58+
self.address_line4,
59+
self.address_line5,
60+
self.post_code,
61+
]
62+
# Filter out empty or None values and join with ', '
63+
return ", ".join([part for part in address_parts if part])
64+
65+
def get_address_line1(self) -> str:
66+
"""
67+
Returns the first address line.
68+
"""
69+
return self.address_line1
70+
71+
def set_address_line1(self, address_line1: str) -> None:
72+
"""
73+
Sets the first address line.
74+
"""
75+
self.address_line1 = address_line1
76+
77+
def get_address_line2(self) -> str:
78+
"""
79+
Returns the second address line.
80+
"""
81+
return self.address_line2
82+
83+
def set_address_line2(self, address_line2: str) -> None:
84+
"""
85+
Sets the second address line.
86+
"""
87+
self.address_line2 = address_line2
88+
89+
def get_address_line3(self) -> str:
90+
"""
91+
Returns the third address line.
92+
"""
93+
return self.address_line3
94+
95+
def set_address_line3(self, address_line3: str) -> None:
96+
"""
97+
Sets the thrid address line.
98+
"""
99+
self.address_line3 = address_line3
100+
101+
def get_address_line4(self) -> str:
102+
"""
103+
Returns the fourth address line.
104+
"""
105+
return self.address_line4
106+
107+
def set_address_line4(self, address_line4: str) -> None:
108+
"""
109+
Sets the fourth address line.
110+
"""
111+
self.address_line4 = address_line4
112+
113+
def get_address_line5(self) -> str:
114+
"""
115+
Returns the fifth address line.
116+
"""
117+
return self.address_line5
118+
119+
def set_address_line5(self, address_line5: str) -> None:
120+
"""
121+
Sets the fifth address line.
122+
"""
123+
self.address_line5 = address_line5
124+
125+
def get_post_code(self) -> str:
126+
"""
127+
Returns the postcodde.
128+
"""
129+
return self.post_code
130+
131+
def set_post_code(self, post_code: str) -> None:
132+
"""
133+
Sets the postcode.
134+
"""
135+
self.post_code = post_code

0 commit comments

Comments
 (0)