Page MenuHomeSoftware Heritage

model: improve a bit the TimestampWithTimezone model
ClosedPublic

Authored by douardda on Mar 12 2020, 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
Branch
wip
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 11100
Build 16735: tox-on-jenkinsJenkins
Build 16734: arc lint + arc unit

Event Timeline

vlorentz added a subscriber: vlorentz.
vlorentz added inline comments.
swh/model/model.py
168

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

180

rename the function to check_negative_utc

This revision is now accepted and ready to land.Mar 12 2020, 4:16 PM
This revision now requires changes to proceed.Mar 12 2020, 4:16 PM
swh/model/model.py
168

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

This revision is now accepted and ready to land.Mar 13 2020, 11:16 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.