mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 11:51:05 -05:00
Convert domain list to YAML
YAML is easier to edit than Python code, and having it in the root directory of the app makes it nice and easy to find.
This commit is contained in:
43
app/domains.yml
Normal file
43
app/domains.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
gov.uk:
|
||||
mod.uk:
|
||||
mil.uk:
|
||||
ddc-mod.org:
|
||||
slc.co.uk:
|
||||
owner: Student Loans Company
|
||||
gov.scot:
|
||||
parliament.uk:
|
||||
owner: Parliament
|
||||
nhs.uk:
|
||||
owner: NHS
|
||||
nhs.net: nhs.uk
|
||||
police.uk:
|
||||
communities.gsi.gov.uk:
|
||||
owner: "Ministry of Housing, Communities & Local Government"
|
||||
dclgdatamart.co.uk: communities.gsi.gov.uk
|
||||
dwp.gov.uk:
|
||||
owner: Deparment for Work and Pensions
|
||||
dwp.gsi.gov.uk: dwp.gov.uk
|
||||
ucds.email: dwp.gov.uk
|
||||
naturalengland.org.uk:
|
||||
Owner: Natural England
|
||||
hmcts.net:
|
||||
owner: Her Majesty’s Courts and Tribunals Service
|
||||
scotent.co.uk:
|
||||
assembly.wales:
|
||||
cjsm.net:
|
||||
cqc.org.uk:
|
||||
bl.uk:
|
||||
owner: British Library
|
||||
stfc.ac.uk:
|
||||
wmfs.net:
|
||||
bbsrc.ac.uk:
|
||||
acas.org.uk:
|
||||
gov.wales:
|
||||
biglotteryfund.org.uk:
|
||||
marinemanagement.org.uk:
|
||||
owner: Marine Management Organisation
|
||||
britishmuseum.org:
|
||||
owner: British Museum
|
||||
derrystrabane.com:
|
||||
highwaysengland.co.uk:
|
||||
76
app/utils.py
76
app/utils.py
@@ -1,5 +1,8 @@
|
||||
import os
|
||||
import re
|
||||
import csv
|
||||
import yaml
|
||||
|
||||
from itertools import chain
|
||||
|
||||
import pytz
|
||||
@@ -438,75 +441,10 @@ class NotGovernmentDomain(Exception):
|
||||
|
||||
class GovernmentDomain:
|
||||
|
||||
domains = {
|
||||
"gov.uk": None,
|
||||
"mod.uk": None,
|
||||
"mil.uk": None,
|
||||
"ddc-mod.org": None,
|
||||
"slc.co.uk": {
|
||||
"owner": "Student Loans Company",
|
||||
"sector": None,
|
||||
"agreement_signed": False,
|
||||
},
|
||||
"gov.scot": None,
|
||||
"parliament.uk": {
|
||||
"owner": "Parliament",
|
||||
"sector": None,
|
||||
"agreement_signed": False,
|
||||
},
|
||||
"nhs.uk": {
|
||||
"owner": "NHS",
|
||||
"sector": None,
|
||||
"agreement_signed": False,
|
||||
},
|
||||
"nhs.net": "nhs.uk",
|
||||
"police.uk": None,
|
||||
"dclgdatamart.co.uk": {
|
||||
"owner": None,
|
||||
"sector": None,
|
||||
"agreement_signed": False,
|
||||
},
|
||||
"dwp.gov.uk": {
|
||||
"owner": "Deparment for Work and Pensions",
|
||||
"sector": None,
|
||||
"agreement_signed": False,
|
||||
},
|
||||
"dwp.gsi.gov.uk": "dwp.gov.uk",
|
||||
"ucds.email": "dwp.gov.uk",
|
||||
"naturalengland.org.uk": {
|
||||
"Owner": "Natural England",
|
||||
"sector": None,
|
||||
"agreement_signed": False,
|
||||
},
|
||||
"hmcts.net": {
|
||||
"owner": "Her Majesty’s Courts and Tribunals Service",
|
||||
"sector": None,
|
||||
"agreement_signed": False,
|
||||
},
|
||||
"scotent.co.uk": None,
|
||||
"assembly.wales": None,
|
||||
"cjsm.net": None,
|
||||
"cqc.org.uk": None,
|
||||
"bl.uk": {
|
||||
"owner": "British Library",
|
||||
"sector": None,
|
||||
"agreement_signed": False,
|
||||
},
|
||||
"stfc.ac.uk": None,
|
||||
"wmfs.net": None,
|
||||
"bbsrc.ac.uk": None,
|
||||
"acas.org.uk": None,
|
||||
"gov.wales": None,
|
||||
"biglotteryfund.org.uk": None,
|
||||
"marinemanagement.org.uk": {
|
||||
"owner": "Marine Management Organisation",
|
||||
},
|
||||
"britishmuseum.org": {
|
||||
"owner": "British Museum",
|
||||
},
|
||||
"derrystrabane.com": None,
|
||||
"highwaysengland.co.uk": None,
|
||||
}
|
||||
_dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
with open('{}/domains.yml'.format(_dir_path)) as domains:
|
||||
domains = yaml.safe_load(domains)
|
||||
|
||||
def __init__(self, email_address_or_domain):
|
||||
|
||||
|
||||
@@ -335,3 +335,26 @@ def test_get_valid_government_domain_some_known_details():
|
||||
assert government_domain.sector is None
|
||||
assert government_domain.owner == "Marine Management Organisation"
|
||||
assert government_domain.agreement_signed is False
|
||||
|
||||
|
||||
def test_validate_government_domain_data():
|
||||
|
||||
for domain in GovernmentDomain.domains.keys():
|
||||
|
||||
government_domain = GovernmentDomain(domain)
|
||||
|
||||
assert government_domain.sector in {
|
||||
'local', 'central', None
|
||||
}
|
||||
|
||||
assert (
|
||||
government_domain.owner is None
|
||||
) or (
|
||||
isinstance(government_domain.owner, str)
|
||||
)
|
||||
|
||||
assert (
|
||||
government_domain.agreement_signed is True
|
||||
) or (
|
||||
government_domain.agreement_signed is False
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user