Skip to content

Commit

Permalink
Add test for require_description flag
Browse files Browse the repository at this point in the history
Add a test which will verify that a missing description triggers an
error when the flag is set.
  • Loading branch information
JeremyMcCormick committed Feb 2, 2024
1 parent 417463c commit 4249f76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ def test_validate_rsp(self) -> None:
result = runner.invoke(
cli, ["validate", "-s", "RSP", "--require-description", TEST_YAML], catch_exceptions=False
)
# This state needs to be reset for subsequent tests.
# This state needs to be reset for subsequent tests. This is not an
# issue when running the actual command line tool as it will execute
# in its own system process.
Schema.require_description(False)
self.assertEqual(result.exit_code, 0)

Expand Down
13 changes: 13 additions & 0 deletions tests/test_datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ def test_validation(self) -> None:
with self.assertRaises(ValidationError):
Column(**units_data)

# Creating a column without a description when required should throw an
# error.
Schema.require_description(True)
with self.assertRaises(ValidationError):
col = Column(
**{
"name": "testColumn",
"@id": "#test_col_id",
"datatype": "string",
}
)
Schema.require_description(False)


class ConstraintTestCase(unittest.TestCase):
"""Test the `UniqueConstraint`, `Index`, `CheckCosntraint`, and
Expand Down

0 comments on commit 4249f76

Please sign in to comment.