Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions meta/type-scope.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
"types": "*",
"note": "Generic over Temporal *: accessor on any temporal type."
},
"temporal_instants": {
"types": "*",
"note": "Generic over Temporal *: the distinct instants of any temporal type, the call behind instants."
},
"temporal_sequences": {
"types": "*",
"note": "Generic over Temporal *: the sequences of any temporal type, the call behind sequences."
},
"temporal_segments": {
"types": "*",
"note": "Generic over Temporal *: the segments of any temporal type, the call behind segments."
},
"temporal_start_instant": {
"types": "*",
"note": "Generic over Temporal *: accessor on any temporal type."
Expand Down
19 changes: 19 additions & 0 deletions tests/test_typescope.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,24 @@ def test_a_declared_scope_is_taken_as_stated(self):
self.assertEqual(kept, FROM_BASE_TSTZSET)


IDL = Path(__file__).resolve().parent.parent / 'output' / 'meos-idl.json'


class DeclaredScopeContractTests(unittest.TestCase):
"""Over the generated catalog, as #CodecContractTests of tests/test_codecs.py reads it: a
function declared generic serves every overload its wrapper declares."""

def setUp(self):
if not IDL.exists():
self.skipTest(f"{IDL} not generated; run `python run.py` first")
self.fns = {f['name']: f for f in json.loads(IDL.read_text())['functions']}

def test_the_array_accessors_serve_every_temporal_type(self):
for name in ('temporal_instants', 'temporal_sequences', 'temporal_segments'):
first = {s['args'][0] for s in self.fns[name].get('sqlSignatures') or ()}
self.assertTrue({'tint', 'tfloat', 'ttext', 'tgeompoint', 'tgeogpoint'} <= first,
f'{name} serves {sorted(first)}')


if __name__ == '__main__':
unittest.main()
Loading