Skip to content

Commit

Permalink
check "calendar" values (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
letmaik authored Jun 22, 2022
1 parent 97b6ee4 commit c278fa8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
10 changes: 9 additions & 1 deletion schemas/referenceSystem.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
"description" : "Temporal reference system",
"properties" :
{
"calendar" : { "type" : "string" },
"calendar" :
{
"type" : "string",
"oneOf" :
[
{ "const" : "Gregorian" },
{ "pattern": "^https?://" }
]
},
"timeScale" : { "type" : "string" }
},
"required" : [ "calendar" ]
Expand Down
33 changes: 31 additions & 2 deletions test/test_referenceSystem.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Pytests to test the referenceSystem.json schema file

# TODO: test that "calendar" is "Gregorian" or a URI

import pytest
from jsonschema.exceptions import ValidationError

Expand Down Expand Up @@ -48,6 +46,26 @@ def test_minimal_temporal_rs(validator):
validator.validate(crs)


def test_http_uri_calendar(validator):
''' Tests a TemporalRS with an HTTP URI calendar '''

crs = {
"type" : "TemporalRS",
"calendar" : "http://some/calendar"
}
validator.validate(crs)


def test_https_uri_calendar(validator):
''' Tests a TemporalRS with an HTTPS URI calendar '''

crs = {
"type" : "TemporalRS",
"calendar" : "https://some/calendar"
}
validator.validate(crs)


def test_identifier_rs(validator):
''' Tests an example of an IdentifierRS '''

Expand Down Expand Up @@ -89,6 +107,17 @@ def test_missing_calendar(validator):
validator.validate(crs)


def test_unknown_non_uri_calendar(validator):
''' Tests a TemporalRS with a missing calendar '''

crs = {
"type" : "TemporalRS",
"calendar" : "Julian"
}
with pytest.raises(ValidationError):
validator.validate(crs)


def test_missing_target_concept(validator):
''' Tests an IdentifierRS with a missing targetConcept '''

Expand Down

0 comments on commit c278fa8

Please sign in to comment.