Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Add a Minor versions constant #264

Merged
merged 4 commits into from
Feb 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
### Added

- [Constants] `STANDARD_VERSIONS_SUPPORTED` lists all versions of the Standard that are fully supported by pyIATI. [#223]
- [Constants] `STANDARD_VERSIONS_MINOR` lists all Minor versions of the IATI Standard. [#264]

- [Datasets] A Dataset `xml_tree` may be set with an ElementTree. [#235]

Expand Down
3 changes: 3 additions & 0 deletions iati/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
]))
"""The major versions of the IATI Standard."""

STANDARD_VERSIONS_MINOR = STANDARD_VERSIONS
"""The minor versions of the IATI Standard."""

LOG_FILE_NAME = 'iatilib.log'
"""The location of the primary IATI log file.

Expand Down
14 changes: 12 additions & 2 deletions iati/tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class TestConstants(object):

@pytest.fixture(params=[
iati.constants.STANDARD_VERSIONS,
iati.constants.STANDARD_VERSIONS_SUPPORTED
iati.constants.STANDARD_VERSIONS_SUPPORTED,
iati.constants.STANDARD_VERSIONS_MINOR
])
def standard_versions_list(self, request):
"""Return a list of Version Numbers."""
Expand All @@ -24,10 +25,15 @@ def test_nsmap(self):
assert isinstance(iati.constants.NSMAP['xsd'], str)

def test_standard_versions_all_are_numbers(self, standard_versions_list):
"""Check that each item in standard versions is a string that can be considered to be a decimal number."""
"""Check that each item in standard versions is a string that can be considered to be a correctly formatted decimal number."""
for version in standard_versions_list:
split_version = version.split('.')

assert isinstance(version, str)
assert float(version)
assert len(split_version) == 2
assert len(split_version[1]) == 2
assert version == version.strip()

def test_standard_versions_correct_format(self, standard_versions_list):
"""Check that standard versions is in the correct format."""
Expand All @@ -49,3 +55,7 @@ def test_standard_versions_major_all_are_integers(self):
def test_standard_versions_major_correct_number(self):
"""Check that the correct number of major versions are detected."""
assert len(iati.constants.STANDARD_VERSIONS_MAJOR) == 2

def test_standard_versions_minor_correct_number(self):
"""Check that the correct number of minor versions are detected."""
assert len(iati.constants.STANDARD_VERSIONS_MINOR) == 7