according to model declaration, a timestamp must be a dict with 2 keys,
'seconds' and 'microseconds'.
Depends on D2912.
Differential D2914
test: ensure timestamp in test data are properly typed douardda on Mar 27 2020, 4:11 PM. Authored by Tags None Subscribers None
Details
Diff Detail
Event TimelineComment Actions Build is green Comment Actions Build is green Patch application report for D2914 (id=10386)Rebasing onto 623a1b75cb... Current branch diff-target is up to date. Changes applied before testcommit ca06d1bf2d43ff9796810a414b9884844e2aea6f Author: David Douard <david.douard@sdfa3.org> Date: Wed Mar 25 16:08:06 2020 +0100 test: ensure timestamp in test data are properly typed according to model declaration, a timestamp must be a dict with 2 keys, 'seconds' and 'microseconds'. Also add a few more tests for the date_to_db helper function so that the test coverage of this later remains. See https://jenkins.softwareheritage.org/job/DSTO/job/tests-on-diff/27/ for more details. Comment Actions It was a comment on your new version on the diff.
I wanted you to add tests checking that int timestamps in revision/release were normalized (though I badly phrased it in my first comment), but you only added tests directly on date_to_db. There is currently no test checking what happens when we do: storage.release_add([{ 'id': b'87659012345678901234', 'name': b'v0.0.1', 'author': { 'name': b'olasd', 'email': b'nic@olasd.fr', 'fullname': b'olasd <nic@olasd.fr>', }, 'date': { 'timestamp': 1234567890, 'offset': 42, 'negative_utc': False, }, 'target': b'43210987654321098765', 'target_type': 'revision', 'message': b'synthetic release', 'synthetic': True, }]) Comment Actions Well, the original comment was
which I understood as "you need to add a test for date_to_db" not "you need to add tests for all functions that use this date_to_db" function.
How is this "normalized"? Is it documented somehow? To me, the model is the final description (and thus documentation) of what data structures are expected. And what we currently have/do is the result of what the code currently support rather than a specified behavior.
Well one idea of unit tests is to not have to test each and every possible execution path of the whole code base... date_to_db is used in release_to_db, since date_to_db is checked, I do not see the real interest of adding a specific test case for this. Also, one could argue that timestamps in a release given with null microseconds given as a dict were not tested before either. And we do want to go to a properly typed usage of structured data in all our APIs. For example it's you who advocated for not using a default value for negative_utc to make sure API users do explicitly specify this flag value. Comment Actions Yes, I phrased it badly.
Indeed, I forgot that _add methods now take model objects, so nvm |