-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#834] iati_orgids: add orgids check option to cli
- Loading branch information
Showing
8 changed files
with
96 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
cove_iati/rulesets/iati_orgids_ruleset/steps/orgids_step_definitions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import re | ||
|
||
from behave import then | ||
|
||
from cove.lib.common import get_orgids_prefixes | ||
from cove_iati.rulesets.utils import get_full_xpath, get_xpaths, register_ruleset_errors | ||
|
||
ORGIDS_PREFIXES = get_orgids_prefixes() | ||
|
||
|
||
@then('`{attribute}` id attribute must start with an org-ids prefix') | ||
@register_ruleset_errors() | ||
def step_openag_org_id_prefix_expected(context, attribute): | ||
errors = [] | ||
fail_msg = '@{} {} does not start with a recognised org-ids prefix' | ||
|
||
for xpath in get_xpaths(context.xml, context.xpath_expression): | ||
attr_id = xpath.attrib.get(attribute, '') | ||
for prefix in ORGIDS_PREFIXES: | ||
if re.match('^%s' % prefix, attr_id): | ||
break | ||
else: | ||
errors.append({'message': fail_msg.format(attribute, attr_id), | ||
'path': '{}/@{}'.format(get_full_xpath(context.xml, xpath), attribute)}) | ||
return context, errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters