2018-03-27 14:30:46 -04:00
|
|
|
"""The unittest.TestCase for JSON Schema tests."""
|
2017-07-31 18:14:18 -04:00
|
|
|
|
2024-05-14 11:07:04 -07:00
|
|
|
from typing import Optional
|
2024-10-10 10:59:18 -07:00
|
|
|
|
2024-05-14 11:07:04 -07:00
|
|
|
from buildscripts.resmokelib import logging
|
2018-03-08 11:58:41 -05:00
|
|
|
from buildscripts.resmokelib.testing.testcases import jsrunnerfile
|
2017-07-31 18:14:18 -04:00
|
|
|
|
2017-09-01 17:40:29 -04:00
|
|
|
|
2018-03-08 11:58:41 -05:00
|
|
|
class JSONSchemaTestCase(jsrunnerfile.JSRunnerFileTestCase):
|
|
|
|
|
"""A JSON Schema test to execute."""
|
2017-07-31 18:14:18 -04:00
|
|
|
|
|
|
|
|
REGISTERED_NAME = "json_schema_test"
|
|
|
|
|
|
2024-05-16 18:00:17 -04:00
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
|
logger: logging.Logger,
|
|
|
|
|
json_filenames: list[str],
|
|
|
|
|
shell_executable: Optional[str] = None,
|
|
|
|
|
shell_options: Optional[dict] = None,
|
|
|
|
|
):
|
2018-03-27 14:30:46 -04:00
|
|
|
"""Initialize the JSONSchemaTestCase with the JSON test file."""
|
2017-07-31 18:14:18 -04:00
|
|
|
|
2024-05-14 11:07:04 -07:00
|
|
|
assert len(json_filenames) == 1
|
|
|
|
|
|
2018-03-08 11:58:41 -05:00
|
|
|
jsrunnerfile.JSRunnerFileTestCase.__init__(
|
2024-05-16 18:00:17 -04:00
|
|
|
self,
|
|
|
|
|
logger,
|
|
|
|
|
"JSON Schema test",
|
|
|
|
|
json_filenames[0],
|
2018-03-08 11:58:41 -05:00
|
|
|
test_runner_file="jstests/libs/json_schema_test_runner.js",
|
2024-05-16 18:00:17 -04:00
|
|
|
shell_executable=shell_executable,
|
|
|
|
|
shell_options=shell_options,
|
|
|
|
|
)
|
2017-07-31 18:14:18 -04:00
|
|
|
|
2018-03-08 11:58:41 -05:00
|
|
|
@property
|
|
|
|
|
def json_filename(self):
|
2018-03-27 14:30:46 -04:00
|
|
|
"""Get the JSON filename."""
|
2018-03-08 11:58:41 -05:00
|
|
|
return self.test_name
|
2017-07-31 18:14:18 -04:00
|
|
|
|
2018-03-08 11:58:41 -05:00
|
|
|
def _populate_test_data(self, test_data):
|
2017-07-31 18:14:18 -04:00
|
|
|
test_data["jsonSchemaTestFile"] = self.json_filename
|
2019-09-16 18:17:40 +00:00
|
|
|
test_data["peerPids"] = self.fixture.pids()
|