-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
Until this point, this is merely tested indirectly. These tests ensure that the equality checks work as expected
Hash functions are dependent on the order of input. Codes in Codelists are stored in a set. This does not have a fixed order. As such, it is necessary to sort the output before hashing. This adds tests that Codelists hash correctly, and fixes the hashing.
Codelist hashing has been fixed
Need to add |
The attribute was added in #45, though the equality and hash checks weren't updated
Failing test - |
A Code with no value isn't very useful.It also confuses use since it cannot be assumed that the value will be a string.
Equality needs checking in both directions |
The __eq__ function takes self and other, with each being handled differently. As such, tests need performing in both directions encase there is an implementation that works one way but not the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small docstring things.
iati/tests/test_codelists.py
Outdated
|
||
@pytest.mark.parametrize('codelist', iati.default.codelists('2.02').values()) | ||
def test_codelist_diff_completeness_not_equal(self, codelist, cmp_func_different): | ||
"""Check that two Codelist with the same codes but different completeness are not deemed to be equal.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codelist
-> Codelists
iati/tests/test_codelists.py
Outdated
|
||
@pytest.mark.parametrize('codelist', iati.default.codelists('2.02').values()) | ||
def test_codelist_diff_num_codes_not_equal(self, codelist, cmp_func_different): | ||
"""Check that two Codelist with the same name but different codes are not deemed to be equal.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codelist -> Codelists
iati/tests/test_codelists.py
Outdated
|
||
@pytest.mark.parametrize('codelist', iati.default.codelists('2.02').values()) | ||
def test_codelist_diff_code_name_not_equal(self, codelist): | ||
"""Check that two Codelist with the same name but a Code with a different name are not deemed to be equal.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codelist -> Codelists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also needs rephrasing as not clear to read.
iati/tests/test_codelists.py
Outdated
|
||
@pytest.mark.parametrize('codelist', iati.default.codelists('2.02').values()) | ||
def test_codelist_diff_code_name_same_hash(self, codelist): | ||
"""Check that two Codelist with the same name but a Code with a different name have the same hash.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codelist -> Codelists + rephrasing
iati/tests/test_codelists.py
Outdated
|
||
@pytest.mark.parametrize('codelist', iati.default.codelists('2.02').values()) | ||
def test_codelist_diff_code_value_not_equal(self, codelist, cmp_func_different): | ||
"""Check that two Codelist with the same name but a Code with a different value are not deemed to be equal.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codelist -> Codelists + rephrasing
@dalepotter @allthatilk Any suggestions on how to rephrase the docstrings? |
This is in response to a review of #247
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐠
Codelists contain Codes within a set. This means that they are in no particular order. Hash functions require input in the same order to produce the same output.
This sorts the Codes in a Codelist before hashing so that Codelists with the same Codes hash the same no matter which order the set provides them in.