Skip to content

Commit

Permalink
Merge pull request #66 from astrodbtoolkit/test_parallax_table
Browse files Browse the repository at this point in the history
Test parallax table
  • Loading branch information
arjunsavel authored Jul 9, 2024
2 parents 0632fd1 + 6248560 commit e3b02be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
8 changes: 7 additions & 1 deletion schema/schema_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,17 @@ class Parallax(Base):
primary_key=True,
)

@validates("comment")
@validates("comments")
def validate_comment_length(self, key, value):
check_string_length(value, 1000, key)
return value

@validates("parallax_mas")
def validate_parallax_value(self, key, value):
if value is None:
raise ValueError(f"Provided {key} is invalid; None: {value}")
return value

# class Measurement(Base):
# # This is a template table that you can fill in with your own measurement.
# . This is a placeholder for a table that would store measurements such as parallax.
Expand Down
19 changes: 19 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Sources,
Telescopes,
Versions,
Parallax,
Regimes
)

Expand Down Expand Up @@ -119,6 +120,24 @@ def test_names(values, error_state):
def test_instruments_schema(values, error_state):
schema_tester(Instruments, values, error_state)

@pytest.mark.parametrize("values, error_state",
[
({"parallax_mas": 30}, None),
({"parallax_mas": -30}, None),
({"parallax_mas": None}, ValueError),
({"parallax_error": None}, None),
({"parallax_error": 30}, None),
({"parallax_error": -30}, None),
({"comments": 'string i will make far too long' * 1000}, ValueError),
({"comments": 'string that i will not make very long'}, None)
])
def test_parallax_schema(values, error_state):
"""
These quantities are validated in the schema. For instance, the schema ensures that
comments must not be more than 1000 characters long.
"""
schema_tester(Parallax, values, error_state)



@pytest.mark.parametrize("values, error_state",
Expand Down

0 comments on commit e3b02be

Please sign in to comment.