From 1582326fd6244000f2e14983cd147b437e354fe6 Mon Sep 17 00:00:00 2001 From: Hayden Date: Tue, 19 Dec 2017 10:25:28 +0000 Subject: [PATCH 1/4] Add a constant to specify minor versions There is one for Major versions, so there should also be one for Minor versions. Consistency. --- iati/constants.py | 3 +++ iati/tests/test_constants.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/iati/constants.py b/iati/constants.py index b68af7aa..6a3e5d17 100644 --- a/iati/constants.py +++ b/iati/constants.py @@ -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. diff --git a/iati/tests/test_constants.py b/iati/tests/test_constants.py index 78cb5bb2..b5cfce32 100644 --- a/iati/tests/test_constants.py +++ b/iati/tests/test_constants.py @@ -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.""" From c0a54e0c1d3180c0228e97f917c04ca7bc24da2e Mon Sep 17 00:00:00 2001 From: Hayden Date: Tue, 19 Dec 2017 10:29:28 +0000 Subject: [PATCH 2/4] Add more checks to verify what a Minor version looks like This checks that values: - use a dot (.) as a decimal separator - have 2 decimal places - do not contain leading or trailing whitespace --- iati/tests/test_constants.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/iati/tests/test_constants.py b/iati/tests/test_constants.py index b5cfce32..20f72ed5 100644 --- a/iati/tests/test_constants.py +++ b/iati/tests/test_constants.py @@ -25,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.""" From 27b42be4f0346acefda2d42423790ae03531d29a Mon Sep 17 00:00:00 2001 From: Hayden Date: Tue, 19 Dec 2017 10:33:12 +0000 Subject: [PATCH 3/4] Update changelog for #264 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed203dcb..7f47219a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] From 2b4f1ed0ae31bd742abd192eb27310c8650a4543 Mon Sep 17 00:00:00 2001 From: Hayden Date: Tue, 19 Dec 2017 10:35:16 +0000 Subject: [PATCH 4/4] Test that there are the correct number of Minor standard versions This will detect if patch versioning is introduced --- iati/tests/test_constants.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/iati/tests/test_constants.py b/iati/tests/test_constants.py index 20f72ed5..5559bd73 100644 --- a/iati/tests/test_constants.py +++ b/iati/tests/test_constants.py @@ -55,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