Page MenuHomeSoftware Heritage

model: improve a bit the TimestampWithTimezone model
ClosedPublic

Authored by douardda on Thu, Mar 12, 4:09 PM.

Details

Summary
  • add a default value for negative_utc,
  • add a validator for negative_utc (can be True iff offset is 0),
  • add low-level tests for it.

Depends on D2823.

Diff Detail

Repository
rDMOD Data Model
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

douardda created this revision.Thu, Mar 12, 4:09 PM
vlorentz accepted this revision.Thu, Mar 12, 4:16 PM
vlorentz added a subscriber: vlorentz.
vlorentz added inline comments.
swh/model/model.py
164–172

I'd prefer to keep it explicit, so loader implementers have to at least think about it

184

rename the function to check_negative_utc

This revision is now accepted and ready to land.Thu, Mar 12, 4:16 PM
vlorentz requested changes to this revision.Thu, Mar 12, 4:16 PM
This revision now requires changes to proceed.Thu, Mar 12, 4:16 PM
douardda added inline comments.Thu, Mar 12, 4:19 PM
swh/model/model.py
164–172

not sure, this attribute really is a pita workaround for a single edge case... but you are probably right here.

douardda updated this revision to Diff 10031.Thu, Mar 12, 5:04 PM

apply vlorentz' comments

vlorentz accepted this revision.Fri, Mar 13, 11:16 AM
This revision is now accepted and ready to land.Fri, Mar 13, 11:16 AM
ardumont accepted this revision.Tue, Mar 31, 9:56 AM

Build is green

Patch application report for D2824 (id=10442)

Could not rebase; Attempt merge onto e9a4c7519e...

Updating e9a4c75..10b0699
Fast-forward
 mypy.ini                           |   4 +-
 requirements.txt                   |   1 +
 swh/model/hypothesis_strategies.py |  20 ++-
 swh/model/model.py                 | 324 ++++++++++++++++++++++++++-----------
 swh/model/tests/test_model.py      | 121 +++++++++++++-
 5 files changed, 369 insertions(+), 101 deletions(-)
Changes applied before test
commit 10b069921e74f0d0411fb105349471e0f9a79f29
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Mar 12 16:01:55 2020 +0100

    model: improve a bit the TimestampWithTimezone model
    
    - add a validator for negative_utc (can be True iff offset is 0),
    - update the timestamps_with_timezone hypothesis strategy,
    - add low-level tests for it.

commit ac9d4c84a115c6c8d3aea04ed55635e8e743ea1d
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Mar 12 14:27:23 2020 +0100

    tests: add low level tests for the Timestamp model entity

commit 85ca7d7848008951f2e26c55c1c72ed9fa92cefb
Author: David Douard <david.douard@sdfa3.org>
Date:   Fri Mar 20 12:59:56 2020 +0100

    model: use attrs_static to enforce type validation of model objects
    
    This ensures all instanciated model entities have valid types for attributes.
    
    Related to T2308.

See https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/20/ for more details.

This revision was automatically updated to reflect the committed changes.