PyPaf 0.5.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.
- {pypaf-0.5.0/src/PyPaf.egg-info → pypaf-0.6.0}/PKG-INFO +49 -4
- {pypaf-0.5.0 → pypaf-0.6.0}/README.md +48 -3
- {pypaf-0.5.0 → pypaf-0.6.0/src/PyPaf.egg-info}/PKG-INFO +49 -4
- {pypaf-0.5.0 → pypaf-0.6.0}/src/PyPaf.egg-info/SOURCES.txt +1 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/address.py +17 -2
- pypaf-0.6.0/src/paf/lineable.py +39 -0
- pypaf-0.6.0/src/paf/version.py +3 -0
- pypaf-0.6.0/tests/test_empty.py +34 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/tests/test_exception_i.py +17 -2
- {pypaf-0.5.0 → pypaf-0.6.0}/tests/test_exception_ii.py +12 -2
- {pypaf-0.5.0 → pypaf-0.6.0}/tests/test_exception_iii.py +12 -2
- pypaf-0.6.0/tests/test_exception_iv.py +190 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/tests/test_mainfile.py +32 -2
- pypaf-0.6.0/tests/test_po_box.py +38 -0
- pypaf-0.6.0/tests/test_rule_1.py +44 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/tests/test_rule_2.py +12 -2
- pypaf-0.6.0/tests/test_rule_3.py +203 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/tests/test_rule_4.py +17 -2
- {pypaf-0.5.0 → pypaf-0.6.0}/tests/test_rule_5.py +38 -4
- pypaf-0.6.0/tests/test_rule_6.py +141 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/tests/test_rule_7.py +61 -6
- pypaf-0.5.0/src/paf/lineable.py +0 -27
- pypaf-0.5.0/src/paf/version.py +0 -3
- pypaf-0.5.0/tests/test_exception_iv.py +0 -100
- pypaf-0.5.0/tests/test_po_box.py +0 -28
- pypaf-0.5.0/tests/test_rule_1.py +0 -29
- pypaf-0.5.0/tests/test_rule_3.py +0 -109
- pypaf-0.5.0/tests/test_rule_6.py +0 -83
- {pypaf-0.5.0 → pypaf-0.6.0}/LICENSE.txt +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/pyproject.toml +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/setup.cfg +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/PyPaf.egg-info/dependency_links.txt +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/PyPaf.egg-info/top_level.txt +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/__init__.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/attribute.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/immutable.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises/__init__.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises/common.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises/rule000.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises/rule001.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises/rule010.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises/rule011.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises/rule101.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises/rule110.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises/rule111.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/premises_extender.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/src/paf/thoroughfare_locality.py +0 -0
- {pypaf-0.5.0 → pypaf-0.6.0}/tests/test_immutability.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: PyPaf
|
|
3
|
-
Version: 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
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
@@ -34,10 +34,25 @@ class Address(ImmutableMixin, LineableMixin):
|
|
|
34
34
|
if not self.is_empty('postcode'):
|
|
35
35
|
yield from [getattr(self, 'postcode')].__iter__()
|
|
36
36
|
|
|
37
|
-
def
|
|
37
|
+
def as_str(self):
|
|
38
38
|
"""Return Address as string"""
|
|
39
39
|
return str(self)
|
|
40
40
|
|
|
41
|
-
def
|
|
41
|
+
def as_list(self):
|
|
42
42
|
"""Return Address as list of strings"""
|
|
43
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,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]))
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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()
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""Test Address Exception IV formatting"""
|
|
2
|
+
|
|
3
|
+
import unittest
|
|
4
|
+
import paf
|
|
5
|
+
|
|
6
|
+
class TestExceptionIVUnit(unittest.TestCase):
|
|
7
|
+
"""Test Address Exception IV Unit"""
|
|
8
|
+
|
|
9
|
+
def setUp(self):
|
|
10
|
+
"""Set up Address instance"""
|
|
11
|
+
self.address = paf.Address({
|
|
12
|
+
'organisation_name': "THE TAMBOURINE WAREHOUSE",
|
|
13
|
+
'building_name': "UNIT 1-3",
|
|
14
|
+
'dependent_thoroughfare_name': "INDUSTRIAL",
|
|
15
|
+
'dependent_thoroughfare_descriptor': "ESTATE",
|
|
16
|
+
'thoroughfare_name': "TAME",
|
|
17
|
+
'thoroughfare_descriptor': "ROAD",
|
|
18
|
+
'post_town': "LONDON",
|
|
19
|
+
'postcode': "E6 7HS"
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
def test_list(self):
|
|
23
|
+
"""Test conversion to an list"""
|
|
24
|
+
address = [
|
|
25
|
+
"THE TAMBOURINE WAREHOUSE",
|
|
26
|
+
"UNIT 1-3",
|
|
27
|
+
"INDUSTRIAL ESTATE",
|
|
28
|
+
"TAME ROAD",
|
|
29
|
+
"LONDON",
|
|
30
|
+
"E6 7HS"
|
|
31
|
+
]
|
|
32
|
+
self.assertEqual(self.address.as_list(), address, "Incorrect Exception IV Unit list format")
|
|
33
|
+
|
|
34
|
+
def test_string(self):
|
|
35
|
+
"""Test conversion to a string"""
|
|
36
|
+
address = "THE TAMBOURINE WAREHOUSE, UNIT 1-3, INDUSTRIAL ESTATE, TAME ROAD, LONDON. E6 7HS"
|
|
37
|
+
self.assertEqual(
|
|
38
|
+
self.address.as_str(), address, "Incorrect Exception IV Unit string format"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
def test_tuple(self):
|
|
42
|
+
"""Test conversion to a tuple"""
|
|
43
|
+
address = (
|
|
44
|
+
"THE TAMBOURINE WAREHOUSE",
|
|
45
|
+
"UNIT 1-3",
|
|
46
|
+
"INDUSTRIAL ESTATE",
|
|
47
|
+
"TAME ROAD",
|
|
48
|
+
"LONDON",
|
|
49
|
+
"E6 7HS"
|
|
50
|
+
)
|
|
51
|
+
self.assertEqual(
|
|
52
|
+
self.address.as_tuple(), address, "Incorrect Exception IV Unit tuple format"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def test_dict(self):
|
|
56
|
+
"""Test conversion to a dict"""
|
|
57
|
+
address = {
|
|
58
|
+
'line_1': "THE TAMBOURINE WAREHOUSE",
|
|
59
|
+
'line_2': "UNIT 1-3",
|
|
60
|
+
'line_3': "INDUSTRIAL ESTATE",
|
|
61
|
+
'line_4': "TAME ROAD",
|
|
62
|
+
'post_town': "LONDON",
|
|
63
|
+
'postcode': "E6 7HS"
|
|
64
|
+
}
|
|
65
|
+
self.assertEqual(
|
|
66
|
+
self.address.as_dict(), address, "Incorrect Exception IV Unit dict format"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
class TestExceptionIVStall(unittest.TestCase):
|
|
70
|
+
"""Test Address Exception IV Stall"""
|
|
71
|
+
|
|
72
|
+
def setUp(self):
|
|
73
|
+
"""Set up Address instance"""
|
|
74
|
+
self.address = paf.Address({
|
|
75
|
+
'organisation_name': "QUIRKY CANDLES LTD",
|
|
76
|
+
'building_name': "STALL 4",
|
|
77
|
+
'thoroughfare_name': "MARKET",
|
|
78
|
+
'thoroughfare_descriptor': "SQUARE",
|
|
79
|
+
'post_town': "LIVERPOOL",
|
|
80
|
+
'postcode': "L8 1LH"
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
def test_list(self):
|
|
84
|
+
"""Test conversion to an list"""
|
|
85
|
+
address = [
|
|
86
|
+
"QUIRKY CANDLES LTD",
|
|
87
|
+
"STALL 4",
|
|
88
|
+
"MARKET SQUARE",
|
|
89
|
+
"LIVERPOOL",
|
|
90
|
+
"L8 1LH"
|
|
91
|
+
]
|
|
92
|
+
self.assertEqual(
|
|
93
|
+
self.address.as_list(), address, "Incorrect Exception IV Stall list format"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
def test_string(self):
|
|
97
|
+
"""Test conversion to a string"""
|
|
98
|
+
address = "QUIRKY CANDLES LTD, STALL 4, MARKET SQUARE, LIVERPOOL. L8 1LH"
|
|
99
|
+
self.assertEqual(
|
|
100
|
+
self.address.as_str(), address, "Incorrect Exception IV Stall string format"
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
def test_tuple(self):
|
|
104
|
+
"""Test conversion to a tuple"""
|
|
105
|
+
address = (
|
|
106
|
+
"QUIRKY CANDLES LTD",
|
|
107
|
+
"STALL 4",
|
|
108
|
+
"MARKET SQUARE",
|
|
109
|
+
"LIVERPOOL",
|
|
110
|
+
"L8 1LH"
|
|
111
|
+
)
|
|
112
|
+
self.assertEqual(
|
|
113
|
+
self.address.as_tuple(), address, "Incorrect Exception IV Stall tuple format"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
def test_dict(self):
|
|
117
|
+
"""Test conversion to a dict"""
|
|
118
|
+
address = {
|
|
119
|
+
'line_1': "QUIRKY CANDLES LTD",
|
|
120
|
+
'line_2': "STALL 4",
|
|
121
|
+
'line_3': "MARKET SQUARE",
|
|
122
|
+
'post_town': "LIVERPOOL",
|
|
123
|
+
'postcode': "L8 1LH"
|
|
124
|
+
}
|
|
125
|
+
self.assertEqual(
|
|
126
|
+
self.address.as_dict(), address, "Incorrect Exception IV Stall dict format"
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
class TestExceptionIVRearOf(unittest.TestCase):
|
|
130
|
+
"""Test Address Exception IV Rear Of"""
|
|
131
|
+
|
|
132
|
+
def setUp(self):
|
|
133
|
+
"""Set up Address instance"""
|
|
134
|
+
self.address = paf.Address({
|
|
135
|
+
'organisation_name': "FIONA'S FLOWERS",
|
|
136
|
+
'building_name': "REAR OF 5A",
|
|
137
|
+
'thoroughfare_name': "HIGH",
|
|
138
|
+
'thoroughfare_descriptor': "STREET",
|
|
139
|
+
'post_town': "GATESHEAD",
|
|
140
|
+
'postcode': "NE8 1BH"
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
def test_list(self):
|
|
144
|
+
"""Test conversion to an list"""
|
|
145
|
+
address = [
|
|
146
|
+
"FIONA'S FLOWERS",
|
|
147
|
+
"REAR OF 5A",
|
|
148
|
+
"HIGH STREET",
|
|
149
|
+
"GATESHEAD",
|
|
150
|
+
"NE8 1BH"
|
|
151
|
+
]
|
|
152
|
+
self.assertEqual(
|
|
153
|
+
self.address.as_list(), address, "Incorrect Exception IV RearOf list format"
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
def test_string(self):
|
|
157
|
+
"""Test conversion to a string"""
|
|
158
|
+
address = "FIONA'S FLOWERS, REAR OF 5A, HIGH STREET, GATESHEAD. NE8 1BH"
|
|
159
|
+
self.assertEqual(
|
|
160
|
+
self.address.as_str(), address, "Incorrect Exception IV RearOf string format"
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
def test_tuple(self):
|
|
164
|
+
"""Test conversion to a tuple"""
|
|
165
|
+
address = (
|
|
166
|
+
"FIONA'S FLOWERS",
|
|
167
|
+
"REAR OF 5A",
|
|
168
|
+
"HIGH STREET",
|
|
169
|
+
"GATESHEAD",
|
|
170
|
+
"NE8 1BH"
|
|
171
|
+
)
|
|
172
|
+
self.assertEqual(
|
|
173
|
+
self.address.as_tuple(), address, "Incorrect Exception IV RearOf tuple format"
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
def test_dict(self):
|
|
177
|
+
"""Test conversion to a dict"""
|
|
178
|
+
address = {
|
|
179
|
+
'line_1': "FIONA'S FLOWERS",
|
|
180
|
+
'line_2': "REAR OF 5A",
|
|
181
|
+
'line_3': "HIGH STREET",
|
|
182
|
+
'post_town': "GATESHEAD",
|
|
183
|
+
'postcode': "NE8 1BH"
|
|
184
|
+
}
|
|
185
|
+
self.assertEqual(
|
|
186
|
+
self.address.as_dict(), address, "Incorrect Exception IV RearOf dict format"
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
if __name__ == '__main__':
|
|
190
|
+
unittest.main()
|