Пример #1
0
 def validate_complete_config(self, config_path):
     schema_path = os.path.join(SUBMITTY_INSTALL_DIR, 'bin', 'json_schemas', 'complete_config_schema.json')
     try:
         submitty_schema_validator.validate_complete_config_schema_using_filenames(config_path, schema_path)
     except submitty_schema_validator.SubmittySchemaException as s:
         s.print_human_readable_error()
         raise
    def test_valid_schemas(self):
        for entry in CONFIGS_DIR.iterdir():
            with self.subTest(f'Validating {entry.name}'):
                if entry.name == 'tutorial_16_docker_network_python.json' or 'notebook' in entry.name:
                    # cannot currently pass, see #5531
                    continue

                validator.validate_complete_config_schema_using_filenames(
                    str(entry), str(SCHEMA_PATH))
                self.assertTrue(True)
Пример #3
0
def main():
    # Parse the argument necessary to find the complete config json.
    args = parse_args()
    # Grab the path to the complete config json for this assignment
    complete_config_json_path = os.path.join(
        SUBMITTY_DATA_DIR, 'courses', args.semester, args.course, 'config',
        'complete_config', f'complete_config_{args.assignment}.json')

    # Get the path to the complete config schema.
    complete_config_schema_path = os.path.join(SUBMITTY_INSTALL_DIR, 'bin',
                                               'json_schemas',
                                               'complete_config_schema.json')

    # Verify that the two files exist
    for json_path in [complete_config_json_path, complete_config_schema_path]:
        if not os.path.isfile(json_path):
            print(
                f"Error, the following file is missing on your system: {json_path}"
            )
            sys.exit(1)

    # Run the schema validator, printing an error on failure.
    try:
        submitty_schema_validator.validate_complete_config_schema_using_filenames(
            complete_config_json_path, complete_config_schema_path, warn=False)
    except submitty_schema_validator.SubmittySchemaException as s:
        s.print_human_readable_error()
        print(
            "The submitty configuration validator detected the above error in your config."
        )
        print(
            "This is a new feature. If you feel that an error was incorrectly identified,"
        )
        print(
            "please submit an error report at https://github.com/Submitty/Submitty"
        )
        print()
    except Exception:
        traceback.print_exc()
Пример #4
0
 def test_valid_schemas(self):
     for entry in CONFIGS_DIR.iterdir():
         with self.subTest(f'Validating {entry.name}'):
             validator.validate_complete_config_schema_using_filenames(
                 str(entry), str(SCHEMA_PATH))
             self.assertTrue(True)