PyPaf 0.4.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {pypaf-0.4.0/src/PyPaf.egg-info → pypaf-0.6.0}/PKG-INFO +49 -4
  2. {pypaf-0.4.0 → pypaf-0.6.0}/README.md +48 -3
  3. {pypaf-0.4.0 → pypaf-0.6.0/src/PyPaf.egg-info}/PKG-INFO +49 -4
  4. {pypaf-0.4.0 → pypaf-0.6.0}/src/PyPaf.egg-info/SOURCES.txt +3 -0
  5. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/address.py +24 -7
  6. pypaf-0.6.0/src/paf/immutable.py +12 -0
  7. pypaf-0.6.0/src/paf/lineable.py +39 -0
  8. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises/rule010.py +3 -3
  9. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises_extender.py +3 -1
  10. pypaf-0.6.0/src/paf/version.py +3 -0
  11. pypaf-0.6.0/tests/test_empty.py +34 -0
  12. {pypaf-0.4.0 → pypaf-0.6.0}/tests/test_exception_i.py +17 -2
  13. {pypaf-0.4.0 → pypaf-0.6.0}/tests/test_exception_ii.py +12 -2
  14. {pypaf-0.4.0 → pypaf-0.6.0}/tests/test_exception_iii.py +12 -2
  15. pypaf-0.6.0/tests/test_exception_iv.py +190 -0
  16. pypaf-0.6.0/tests/test_immutability.py +38 -0
  17. {pypaf-0.4.0 → pypaf-0.6.0}/tests/test_mainfile.py +32 -2
  18. pypaf-0.6.0/tests/test_po_box.py +38 -0
  19. pypaf-0.6.0/tests/test_rule_1.py +44 -0
  20. {pypaf-0.4.0 → pypaf-0.6.0}/tests/test_rule_2.py +12 -2
  21. pypaf-0.6.0/tests/test_rule_3.py +203 -0
  22. {pypaf-0.4.0 → pypaf-0.6.0}/tests/test_rule_4.py +17 -2
  23. {pypaf-0.4.0 → pypaf-0.6.0}/tests/test_rule_5.py +38 -4
  24. pypaf-0.6.0/tests/test_rule_6.py +141 -0
  25. {pypaf-0.4.0 → pypaf-0.6.0}/tests/test_rule_7.py +61 -6
  26. pypaf-0.4.0/src/paf/lineable.py +0 -27
  27. pypaf-0.4.0/src/paf/version.py +0 -3
  28. pypaf-0.4.0/tests/test_exception_iv.py +0 -100
  29. pypaf-0.4.0/tests/test_po_box.py +0 -28
  30. pypaf-0.4.0/tests/test_rule_1.py +0 -29
  31. pypaf-0.4.0/tests/test_rule_3.py +0 -109
  32. pypaf-0.4.0/tests/test_rule_6.py +0 -83
  33. {pypaf-0.4.0 → pypaf-0.6.0}/LICENSE.txt +0 -0
  34. {pypaf-0.4.0 → pypaf-0.6.0}/pyproject.toml +0 -0
  35. {pypaf-0.4.0 → pypaf-0.6.0}/setup.cfg +0 -0
  36. {pypaf-0.4.0 → pypaf-0.6.0}/src/PyPaf.egg-info/dependency_links.txt +0 -0
  37. {pypaf-0.4.0 → pypaf-0.6.0}/src/PyPaf.egg-info/top_level.txt +0 -0
  38. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/__init__.py +0 -0
  39. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/attribute.py +0 -0
  40. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises/__init__.py +0 -0
  41. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises/common.py +0 -0
  42. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises/rule000.py +0 -0
  43. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises/rule001.py +0 -0
  44. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises/rule011.py +0 -0
  45. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises/rule101.py +0 -0
  46. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises/rule110.py +0 -0
  47. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/premises/rule111.py +0 -0
  48. {pypaf-0.4.0 → pypaf-0.6.0}/src/paf/thoroughfare_locality.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyPaf
3
- Version: 0.4.0
3
+ Version: 0.6.0
4
4
  Summary: Formats the elements of a Royal Mail Postcode Address File entry
5
5
  Author-email: John Bard <johnbard@globalnet.co.uk>
6
6
  License: MIT
@@ -25,7 +25,7 @@ Install it from PyPI:
25
25
 
26
26
  ## Usage
27
27
 
28
- May be used to format the PAF Address elements as an array of strings:
28
+ May be used to format the PAF Address elements as a list of strings:
29
29
 
30
30
  ```python
31
31
  import paf
@@ -37,11 +37,28 @@ address = paf.Address({
37
37
  'post_town': "HIGH WYCOMBE",
38
38
  'postcode': "HP10 8LS"
39
39
  })
40
- address.list() # or list(address)
40
+ address.as_list() # or list(address)
41
41
 
42
42
  ['1-2 NURSERY LANE', 'PENN', 'HIGH WYCOMBE', 'HP10 8LS']
43
43
  ```
44
44
 
45
+ Or as a tuple of strings:
46
+
47
+ ```python
48
+ import paf
49
+ address = paf.Address({
50
+ 'building_name': "1-2",
51
+ 'thoroughfare_name': "NURSERY",
52
+ 'thoroughfare_descriptor': "LANE",
53
+ 'dependent_locality': "PENN",
54
+ 'post_town': "HIGH WYCOMBE",
55
+ 'postcode': "HP10 8LS"
56
+ })
57
+ address.as_tuple() # or tuple(address)
58
+
59
+ ('1-2 NURSERY LANE', 'PENN', 'HIGH WYCOMBE', 'HP10 8LS')
60
+ ```
61
+
45
62
  Or as a single string:
46
63
 
47
64
  ```python
@@ -54,11 +71,39 @@ address = paf.Address({
54
71
  'post_town': "HIGH WYCOMBE",
55
72
  'postcode': "HP10 8LS"
56
73
  })
57
- address.str() # or str(address)
74
+ address.as_str() # or str(address)
58
75
 
59
76
  '1-2 NURSERY LANE, PENN, HIGH WYCOMBE. HP10 8LS'
60
77
  ```
61
78
 
79
+ Or as a dictionary:
80
+
81
+ ```python
82
+ import paf
83
+ address = paf.Address({
84
+ 'building_name': "1-2",
85
+ 'thoroughfare_name': "NURSERY",
86
+ 'thoroughfare_descriptor': "LANE",
87
+ 'dependent_locality': "PENN",
88
+ 'post_town': "HIGH WYCOMBE",
89
+ 'postcode': "HP10 8LS"
90
+ })
91
+ address.as_dict()
92
+
93
+ {
94
+ 'line_1': "1-2 NURSERY LANE",
95
+ 'line_2': "PENN",
96
+ 'post_town': "HIGH WYCOMBE",
97
+ 'postcode': "HP10 8LS"
98
+ }
99
+ ```
100
+
101
+ ## Development
102
+
103
+ After checking out the repo, run `pytest` to run the tests.
104
+
105
+ To release a new version, update the version number in `version.py`, and then run `python -m build`, which will create a distribution archive. Run `python -m twine upload dist/*`, to upload the distribution archive to [pypi.org](https://pypi.org).
106
+
62
107
  ## Contributing
63
108
 
64
109
  Bug reports and pull requests are welcome on GitHub at https://github.com/drabjay/pypaf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -10,7 +10,7 @@ Install it from PyPI:
10
10
 
11
11
  ## Usage
12
12
 
13
- May be used to format the PAF Address elements as an array of strings:
13
+ May be used to format the PAF Address elements as a list of strings:
14
14
 
15
15
  ```python
16
16
  import paf
@@ -22,11 +22,28 @@ address = paf.Address({
22
22
  'post_town': "HIGH WYCOMBE",
23
23
  'postcode': "HP10 8LS"
24
24
  })
25
- address.list() # or list(address)
25
+ address.as_list() # or list(address)
26
26
 
27
27
  ['1-2 NURSERY LANE', 'PENN', 'HIGH WYCOMBE', 'HP10 8LS']
28
28
  ```
29
29
 
30
+ Or as a tuple of strings:
31
+
32
+ ```python
33
+ import paf
34
+ address = paf.Address({
35
+ 'building_name': "1-2",
36
+ 'thoroughfare_name': "NURSERY",
37
+ 'thoroughfare_descriptor': "LANE",
38
+ 'dependent_locality': "PENN",
39
+ 'post_town': "HIGH WYCOMBE",
40
+ 'postcode': "HP10 8LS"
41
+ })
42
+ address.as_tuple() # or tuple(address)
43
+
44
+ ('1-2 NURSERY LANE', 'PENN', 'HIGH WYCOMBE', 'HP10 8LS')
45
+ ```
46
+
30
47
  Or as a single string:
31
48
 
32
49
  ```python
@@ -39,11 +56,39 @@ address = paf.Address({
39
56
  'post_town': "HIGH WYCOMBE",
40
57
  'postcode': "HP10 8LS"
41
58
  })
42
- address.str() # or str(address)
59
+ address.as_str() # or str(address)
43
60
 
44
61
  '1-2 NURSERY LANE, PENN, HIGH WYCOMBE. HP10 8LS'
45
62
  ```
46
63
 
64
+ Or as a dictionary:
65
+
66
+ ```python
67
+ import paf
68
+ address = paf.Address({
69
+ 'building_name': "1-2",
70
+ 'thoroughfare_name': "NURSERY",
71
+ 'thoroughfare_descriptor': "LANE",
72
+ 'dependent_locality': "PENN",
73
+ 'post_town': "HIGH WYCOMBE",
74
+ 'postcode': "HP10 8LS"
75
+ })
76
+ address.as_dict()
77
+
78
+ {
79
+ 'line_1': "1-2 NURSERY LANE",
80
+ 'line_2': "PENN",
81
+ 'post_town': "HIGH WYCOMBE",
82
+ 'postcode': "HP10 8LS"
83
+ }
84
+ ```
85
+
86
+ ## Development
87
+
88
+ After checking out the repo, run `pytest` to run the tests.
89
+
90
+ To release a new version, update the version number in `version.py`, and then run `python -m build`, which will create a distribution archive. Run `python -m twine upload dist/*`, to upload the distribution archive to [pypi.org](https://pypi.org).
91
+
47
92
  ## Contributing
48
93
 
49
94
  Bug reports and pull requests are welcome on GitHub at https://github.com/drabjay/pypaf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyPaf
3
- Version: 0.4.0
3
+ Version: 0.6.0
4
4
  Summary: Formats the elements of a Royal Mail Postcode Address File entry
5
5
  Author-email: John Bard <johnbard@globalnet.co.uk>
6
6
  License: MIT
@@ -25,7 +25,7 @@ Install it from PyPI:
25
25
 
26
26
  ## Usage
27
27
 
28
- May be used to format the PAF Address elements as an array of strings:
28
+ May be used to format the PAF Address elements as a list of strings:
29
29
 
30
30
  ```python
31
31
  import paf
@@ -37,11 +37,28 @@ address = paf.Address({
37
37
  'post_town': "HIGH WYCOMBE",
38
38
  'postcode': "HP10 8LS"
39
39
  })
40
- address.list() # or list(address)
40
+ address.as_list() # or list(address)
41
41
 
42
42
  ['1-2 NURSERY LANE', 'PENN', 'HIGH WYCOMBE', 'HP10 8LS']
43
43
  ```
44
44
 
45
+ Or as a tuple of strings:
46
+
47
+ ```python
48
+ import paf
49
+ address = paf.Address({
50
+ 'building_name': "1-2",
51
+ 'thoroughfare_name': "NURSERY",
52
+ 'thoroughfare_descriptor': "LANE",
53
+ 'dependent_locality': "PENN",
54
+ 'post_town': "HIGH WYCOMBE",
55
+ 'postcode': "HP10 8LS"
56
+ })
57
+ address.as_tuple() # or tuple(address)
58
+
59
+ ('1-2 NURSERY LANE', 'PENN', 'HIGH WYCOMBE', 'HP10 8LS')
60
+ ```
61
+
45
62
  Or as a single string:
46
63
 
47
64
  ```python
@@ -54,11 +71,39 @@ address = paf.Address({
54
71
  'post_town': "HIGH WYCOMBE",
55
72
  'postcode': "HP10 8LS"
56
73
  })
57
- address.str() # or str(address)
74
+ address.as_str() # or str(address)
58
75
 
59
76
  '1-2 NURSERY LANE, PENN, HIGH WYCOMBE. HP10 8LS'
60
77
  ```
61
78
 
79
+ Or as a dictionary:
80
+
81
+ ```python
82
+ import paf
83
+ address = paf.Address({
84
+ 'building_name': "1-2",
85
+ 'thoroughfare_name': "NURSERY",
86
+ 'thoroughfare_descriptor': "LANE",
87
+ 'dependent_locality': "PENN",
88
+ 'post_town': "HIGH WYCOMBE",
89
+ 'postcode': "HP10 8LS"
90
+ })
91
+ address.as_dict()
92
+
93
+ {
94
+ 'line_1': "1-2 NURSERY LANE",
95
+ 'line_2': "PENN",
96
+ 'post_town': "HIGH WYCOMBE",
97
+ 'postcode': "HP10 8LS"
98
+ }
99
+ ```
100
+
101
+ ## Development
102
+
103
+ After checking out the repo, run `pytest` to run the tests.
104
+
105
+ To release a new version, update the version number in `version.py`, and then run `python -m build`, which will create a distribution archive. Run `python -m twine upload dist/*`, to upload the distribution archive to [pypi.org](https://pypi.org).
106
+
62
107
  ## Contributing
63
108
 
64
109
  Bug reports and pull requests are welcome on GitHub at https://github.com/drabjay/pypaf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -8,6 +8,7 @@ src/PyPaf.egg-info/top_level.txt
8
8
  src/paf/__init__.py
9
9
  src/paf/address.py
10
10
  src/paf/attribute.py
11
+ src/paf/immutable.py
11
12
  src/paf/lineable.py
12
13
  src/paf/premises_extender.py
13
14
  src/paf/thoroughfare_locality.py
@@ -21,10 +22,12 @@ src/paf/premises/rule011.py
21
22
  src/paf/premises/rule101.py
22
23
  src/paf/premises/rule110.py
23
24
  src/paf/premises/rule111.py
25
+ tests/test_empty.py
24
26
  tests/test_exception_i.py
25
27
  tests/test_exception_ii.py
26
28
  tests/test_exception_iii.py
27
29
  tests/test_exception_iv.py
30
+ tests/test_immutability.py
28
31
  tests/test_mainfile.py
29
32
  tests/test_po_box.py
30
33
  tests/test_rule_1.py
@@ -1,22 +1,24 @@
1
1
  """PAF Address"""
2
2
 
3
+ # Tried using dataclasses.dataclass(frozen=True) decorator for immutablity but did not work"""
4
+ from .immutable import ImmutableMixin
3
5
  from .lineable import LineableMixin
4
6
 
5
- class Address(LineableMixin):
7
+ class Address(ImmutableMixin, LineableMixin):
6
8
  """Main PAF Address class"""
7
9
 
8
10
  def __init__(self, args):
9
11
  """Initialise Address elements"""
10
- for key in self.__class__.attrs:
11
- setattr(self, key, '')
12
+ for key in self.__class__.attrs: # pylint: disable=not-an-iterable
13
+ object.__setattr__(self, key, '')
12
14
  for key, val in args.items():
13
15
  if hasattr(self, key):
14
- setattr(self, key, val)
16
+ object.__setattr__(self, key, val)
15
17
  self.extend_premises()
16
18
 
17
19
  def __repr__(self):
18
20
  """Return full representation of an Address"""
19
- args = {k: getattr(self, k) for k in self.__class__.attrs if getattr(self, k, None)}
21
+ args = {k: getattr(self, k) for k in self.__class__.attrs if getattr(self, k, None)} # pylint: disable=not-an-iterable
20
22
  return self.__class__.__name__ + '(' + str(args) + ')'
21
23
 
22
24
  def __str__(self):
@@ -32,10 +34,25 @@ class Address(LineableMixin):
32
34
  if not self.is_empty('postcode'):
33
35
  yield from [getattr(self, 'postcode')].__iter__()
34
36
 
35
- def str(self):
37
+ def as_str(self):
36
38
  """Return Address as string"""
37
39
  return str(self)
38
40
 
39
- def list(self):
41
+ def as_list(self):
40
42
  """Return Address as list of strings"""
41
43
  return list(self)
44
+
45
+ def as_tuple(self):
46
+ """Return Address as tuple of strings"""
47
+ return tuple(self)
48
+
49
+ def as_dict(self):
50
+ """Return Address as dictionary of strings"""
51
+ address = {}
52
+ for counter, line in enumerate(getattr(self, 'optional_lines'), 1):
53
+ address[f"line_{counter}"] = line
54
+ if not self.is_empty('post_town'):
55
+ address['post_town'] = getattr(self, 'post_town')
56
+ if not self.is_empty('postcode'):
57
+ address['postcode'] = getattr(self, 'postcode')
58
+ return address
@@ -0,0 +1,12 @@
1
+ """Immutable Mixin"""
2
+
3
+ from dataclasses import FrozenInstanceError
4
+
5
+ class ImmutableMixin():
6
+ """Prevent manipulation of object attributes"""
7
+
8
+ def __setattr__(self, *_):
9
+ raise FrozenInstanceError
10
+
11
+ def __delattr__(self, *_):
12
+ raise FrozenInstanceError
@@ -0,0 +1,39 @@
1
+ """Lineable Mixin"""
2
+
3
+ from itertools import chain
4
+ from .thoroughfare_locality import ThoroughfareLocalityMixin
5
+
6
+ class LineableMixin(ThoroughfareLocalityMixin):
7
+ """Converts Paf address elements into list of address lines"""
8
+
9
+ @classmethod
10
+ @property
11
+ def optional_lines_attrs(cls):
12
+ """Returns optional Paf address line attributes"""
13
+ return cls.organisation_attrs + ['po_box', 'premises', 'thoroughfares_and_localities']
14
+
15
+ @classmethod
16
+ @property
17
+ def lines_attrs(cls):
18
+ """Returns optional Paf address line attributes and post_town"""
19
+ return cls.optional_lines_attrs + ['post_town']
20
+
21
+ @property
22
+ def optional_lines(self):
23
+ """Returns Paf as list of address lines, excluding post_town and postcode"""
24
+ return self._lines(self.__class__.optional_lines_attrs)
25
+
26
+ @property
27
+ def lines(self):
28
+ """Returns Paf as list of address lines, excluding postcode"""
29
+ return self._lines(self.__class__.lines_attrs)
30
+
31
+ @property
32
+ def po_box(self):
33
+ """Returns PO Box"""
34
+ return '' if self.is_empty('po_box_number') else f"PO BOX {getattr(self, 'po_box_number')}"
35
+
36
+ def _lines(self, attrs):
37
+ """Returns list of address lines from specified attributes"""
38
+ lines = list(filter(None, [getattr(self, k, None) for k in attrs]))
39
+ return list(chain(*[line if isinstance(line, list) else [line] for line in lines]))
@@ -26,12 +26,12 @@ class Rule010(Common):
26
26
  return(
27
27
  self.is_exception('building_name_last_word') and
28
28
  not re.match(r'^\d+$', self.building_name_last_word) and
29
- not self.is_non_split_building_name
29
+ not self.is_known_building_type
30
30
  )
31
31
 
32
32
  @property
33
- def is_non_split_building_name(self):
34
- """Returns if building name should not be split based on all but last word"""
33
+ def is_known_building_type(self):
34
+ """Returns if building name starts with a known building type"""
35
35
  return self.building_name_but_last_word in [
36
36
  "BACK OF", "BLOCK", "BLOCKS", "BUILDING", "MAISONETTE", "MAISONETTES", "REAR OF",
37
37
  "SHOP", "SHOPS", "STALL", "STALLS", "SUITE", "SUITES", "UNIT", "UNITS"
@@ -22,4 +22,6 @@ class PremisesExtenderMixin(AttributeMixin):
22
22
  def extend_premises(self):
23
23
  """Dynamically extends instance with appropriate premises rule"""
24
24
  base_cls = self.__class__
25
- self.__class__ = type(base_cls.__name__, (base_cls, self.premises_rule), {})
25
+ object.__setattr__(
26
+ self, '__class__', type(base_cls.__name__, (base_cls, self.premises_rule), {})
27
+ )
@@ -0,0 +1,3 @@
1
+ """Version"""
2
+
3
+ __version__ = '0.6.0'
@@ -0,0 +1,34 @@
1
+ """Test Empty Address formatting"""
2
+
3
+ import unittest
4
+ import paf
5
+
6
+ class TestEmpty(unittest.TestCase):
7
+ """Test Address Exception I"""
8
+
9
+ def setUp(self):
10
+ """Set up Address instance"""
11
+ self.address = paf.Address({})
12
+
13
+ def test_list(self):
14
+ """Test conversion to an list"""
15
+ address = []
16
+ self.assertEqual(self.address.as_list(), address, "Incorrect empty list format")
17
+
18
+ def test_string(self):
19
+ """Test conversion to a string"""
20
+ address = ""
21
+ self.assertEqual(self.address.as_str(), address, "Incorrect empty string format")
22
+
23
+ def test_tuple(self):
24
+ """Test conversion to a tuple"""
25
+ address = ()
26
+ self.assertEqual(self.address.as_tuple(), address, "Incorrect empty tuple format")
27
+
28
+ def test_dict(self):
29
+ """Test conversion to a dict"""
30
+ address = {}
31
+ self.assertEqual(self.address.as_dict(), address, "Incorrect empty dict format")
32
+
33
+ if __name__ == '__main__':
34
+ unittest.main()
@@ -20,12 +20,27 @@ class TestExceptionI(unittest.TestCase):
20
20
  def test_list(self):
21
21
  """Test conversion to an list"""
22
22
  address = ["1-2 NURSERY LANE", "PENN", "HIGH WYCOMBE", "HP10 8LS"]
23
- self.assertEqual(self.address.list(), address, "Incorrect Exception I list format")
23
+ self.assertEqual(self.address.as_list(), address, "Incorrect Exception I list format")
24
24
 
25
25
  def test_string(self):
26
26
  """Test conversion to a string"""
27
27
  address = "1-2 NURSERY LANE, PENN, HIGH WYCOMBE. HP10 8LS"
28
- self.assertEqual(self.address.str(), address, "Incorrect Exception I string format")
28
+ self.assertEqual(self.address.as_str(), address, "Incorrect Exception I string format")
29
+
30
+ def test_tuple(self):
31
+ """Test conversion to a tuple"""
32
+ address = ("1-2 NURSERY LANE", "PENN", "HIGH WYCOMBE", "HP10 8LS")
33
+ self.assertEqual(self.address.as_tuple(), address, "Incorrect Exception I tuple format")
34
+
35
+ def test_dict(self):
36
+ """Test conversion to a dict"""
37
+ address = {
38
+ 'line_1': "1-2 NURSERY LANE",
39
+ 'line_2': "PENN",
40
+ 'post_town': "HIGH WYCOMBE",
41
+ 'postcode': "HP10 8LS"
42
+ }
43
+ self.assertEqual(self.address.as_dict(), address, "Incorrect Exception I dict format")
29
44
 
30
45
  if __name__ == '__main__':
31
46
  unittest.main()
@@ -18,12 +18,22 @@ class TestExceptionII(unittest.TestCase):
18
18
  def test_list(self):
19
19
  """Test conversion to an list"""
20
20
  address = ["12A UPPERKIRKGATE", "ABERDEEN", "AB10 1BA"]
21
- self.assertEqual(self.address.list(), address, "Incorrect Exception II list format")
21
+ self.assertEqual(self.address.as_list(), address, "Incorrect Exception II list format")
22
22
 
23
23
  def test_string(self):
24
24
  """Test conversion to a string"""
25
25
  address = "12A UPPERKIRKGATE, ABERDEEN. AB10 1BA"
26
- self.assertEqual(self.address.str(), address, "Incorrect Exception II string format")
26
+ self.assertEqual(self.address.as_str(), address, "Incorrect Exception II string format")
27
+
28
+ def test_tuple(self):
29
+ """Test conversion to a tuple"""
30
+ address = ("12A UPPERKIRKGATE", "ABERDEEN", "AB10 1BA")
31
+ self.assertEqual(self.address.as_tuple(), address, "Incorrect Exception II tuple format")
32
+
33
+ def test_dict(self):
34
+ """Test conversion to a dict"""
35
+ address = {'line_1': "12A UPPERKIRKGATE", 'post_town': "ABERDEEN", 'postcode': "AB10 1BA"}
36
+ self.assertEqual(self.address.as_dict(), address, "Incorrect Exception II dict format")
27
37
 
28
38
  if __name__ == '__main__':
29
39
  unittest.main()
@@ -19,12 +19,22 @@ class TestExceptionIII(unittest.TestCase):
19
19
  def test_list(self):
20
20
  """Test conversion to an list"""
21
21
  address = ["K PORTLAND ROAD", "DORKING", "RH4 1EW"]
22
- self.assertEqual(self.address.list(), address, "Incorrect Exception III list format")
22
+ self.assertEqual(self.address.as_list(), address, "Incorrect Exception III list format")
23
23
 
24
24
  def test_string(self):
25
25
  """Test conversion to a string"""
26
26
  address = "K PORTLAND ROAD, DORKING. RH4 1EW"
27
- self.assertEqual(self.address.str(), address, "Incorrect Exception III string format")
27
+ self.assertEqual(self.address.as_str(), address, "Incorrect Exception III string format")
28
+
29
+ def test_tuple(self):
30
+ """Test conversion to a tuple"""
31
+ address = ("K PORTLAND ROAD", "DORKING", "RH4 1EW")
32
+ self.assertEqual(self.address.as_tuple(), address, "Incorrect Exception III tuple format")
33
+
34
+ def test_dict(self):
35
+ """Test conversion to a dict"""
36
+ address = {'line_1': "K PORTLAND ROAD", 'post_town': "DORKING", 'postcode': "RH4 1EW"}
37
+ self.assertEqual(self.address.as_dict(), address, "Incorrect Exception III dict format")
28
38
 
29
39
  if __name__ == '__main__':
30
40
  unittest.main()