Skip to content

Commit

Permalink
Add Senedd election type
Browse files Browse the repository at this point in the history
  • Loading branch information
symroe committed Oct 27, 2020
1 parent 3d7f574 commit 53e30d7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## :package: [0.3.0](https://pypi.org/project/uk-election-ids/0.3.0/) - 2020-10-27

Added `senedd` election type

## :package: [0.2.1](https://pypi.org/project/uk-election-ids/0.2.1/) - 2019-10-16

Tested on Python 3.8
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _get_description():

setup(
name="uk_election_ids",
version="0.2.1",
version="0.3.0",
author="chris48s",
license="MIT",
url="https://github.com/DemocracyClub/uk-election-ids/",
Expand Down
10 changes: 5 additions & 5 deletions tests/test_id_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_string_date(self):
self.assertEqual("parl.2018-05-03", election_id)

def test_naw_sp_without_subtype(self):
for election_type in ("naw", "sp"):
for election_type in ("naw", "sp", "senedd"):
id = IdBuilder(election_type, date(2018, 5, 3)).with_division(
"test-division"
)
Expand All @@ -37,12 +37,12 @@ def test_naw_sp_without_subtype(self):
self.assertEqual(["%s.2018-05-03" % (election_type)], id.ids)

def test_naw_sp_invalid_subtype(self):
for election_type in ("naw", "sp"):
for election_type in ("naw", "sp", "senedd"):
with self.assertRaises(ValueError):
IdBuilder(election_type, date(2018, 5, 3)).with_subtype("x")

def test_naw_sp_valid_subtype_no_division(self):
for election_type in ("naw", "sp"):
for election_type in ("naw", "sp", "senedd"):
id = IdBuilder(election_type, date(2018, 5, 3)).with_subtype("c")
election_id = id.election_group_id
self.assertEqual("%s.2018-05-03" % (election_type), election_id)
Expand All @@ -61,12 +61,12 @@ def test_naw_sp_valid_subtype_no_division(self):
)

def test_naw_sp_with_org(self):
for election_type in ("naw", "sp"):
for election_type in ("naw", "sp", "senedd"):
with self.assertRaises(ValueError):
IdBuilder(election_type, date(2018, 5, 3)).with_organisation("test-org")

def test_naw_sp_with_division(self):
for election_type in ("naw", "sp"):
for election_type in ("naw", "sp", "senedd"):
id = (
IdBuilder(election_type, date(2018, 5, 3))
.with_subtype("r")
Expand Down
10 changes: 10 additions & 0 deletions uk_election_ids/datapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
"can_have_orgs": False,
"can_have_divs": True,
},
"senedd": {
"name": "Senedd Cymru elections",
"subtypes": [
{"name": "Constituencies", "election_subtype": "c"},
{"name": "Regions", "election_subtype": "r"},
],
"default_voting_system": "AMS",
"can_have_orgs": False,
"can_have_divs": True,
},
"sp": {
"name": "Scottish Parliament elections",
"subtypes": [
Expand Down
2 changes: 1 addition & 1 deletion uk_election_ids/election_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, election_type, date):
Args:
election_type (str): May be one of
``['europarl', 'gla', 'local', 'mayor', 'naw', 'nia', 'parl', 'pcc', 'sp']``
``['europarl', 'gla', 'local', 'mayor', 'naw', 'nia', 'parl', 'pcc', 'sp', 'senedd']``
date (date|str): May be either a python date object,
or a string in 'Y-m-d' format.
``myid = IdBuilder('local', date(2018, 5, 3))`` and
Expand Down

0 comments on commit 53e30d7

Please sign in to comment.