Example #1
0
 def test_empty(self, datafiles):
     yaml_file_path = datafiles.listdir()[0]
     with pytest.raises(Exception) as context:
         schema_validation.validate_yaml(yaml_file_path, __schema_url__)
     assert 'Wrong Yaml structure' in str(context.value)
     assert 'None is not of type \'object\'' in str(context.value)
     assert 'On instance:\nNone' in str(context.value)
Example #2
0
def cli(file, refresh, schema_url):
    """Verify that the yaml FILE matches the neoload as-code file format"""
    try:
        schema_validation.validate_yaml(file, schema_url if refresh else None)
    except Exception as err:
        raise cli_exception.CliException(str(err))
    print('Yaml file is valid.')
Example #3
0
 def test_broken_yaml(self, datafiles):
     yaml_file_path = datafiles.listdir()[0]
     with pytest.raises(Exception) as context:
         schema_validation.validate_yaml(yaml_file_path, __schema_url__)
     assert 'This is not a valid yaml file' in str(context.value)
     assert 'while scanning a simple key' in str(context.value)
     assert 'could not find expected \':\'' in str(context.value)
     assert 'line 3, column 1' in str(context.value)
Example #4
0
 def test_no_file(self, datafiles):
     with pytest.raises(Exception) as context:
         schema_validation.validate_yaml('/invalid/yaml/file_path',
                                         __schema_url__)
     assert 'Unable to open file /invalid/yaml/file_path:' in str(
         context.value)
     assert 'No such file or directory: \'/invalid/yaml/file_path\'' in str(
         context.value)
     print(context.value)
Example #5
0
 def test_invalid_to_schema(self, datafiles):
     yaml_file_path = datafiles.listdir()[0]
     with pytest.raises(Exception) as context:
         schema_validation.validate_yaml(yaml_file_path, __schema_url__)
     assert 'Wrong Yaml structure' in str(context.value)
     assert 'Additional properties are not allowed (\'ifyourelookingforcutthroat\' was unexpected)' in str(
         context.value)
     assert 'On instance:\n{\'name\': \'NeoLoad-CLI-example-2_0' in str(
         context.value)
Example #6
0
def cli(file, refresh, schema_url, ssl_cert):
    """Verify that the yaml FILE matches the neoload as-code file format"""

    path = os.path.abspath(file)
    try:
        if os.path.isdir(path):
            schema_validation.validate_yaml_dir(path, schema_url, ssl_cert)
            print('All yaml files underneath the path provided are valid.')
        else:
            schema_validation.validate_yaml(file, schema_url, ssl_cert)
            print('Yaml file is valid.')
    except Exception as err:
        raise cli_exception.CliException(str(err))
Example #7
0
def cli(file, refresh, schema_url, ssl_cert):
    """Verify that the yaml FILE matches the neoload as-code file format"""

    force_schema = os.environ.get('NLCLI_FORCE_SCHEMA')
    if force_schema is not None and len(force_schema) > 0:
        schema_url = force_schema

    path = os.path.abspath(file)
    try:
        if os.path.isdir(path):
            schema_validation.validate_yaml_dir(path, schema_url, ssl_cert)
            print('All yaml files underneath the path provided are valid.')
        else:
            schema_validation.validate_yaml(file, schema_url, ssl_cert)
            print('Yaml file is valid.')
    except Exception as err:
        raise cli_exception.CliException(str(err))
Example #8
0
 def test_success(self, datafiles):
     yaml_file_path = datafiles.listdir()[0]
     schema_validation.validate_yaml(yaml_file_path, __schema_url__)
Example #9
0
 def test_invalid_to_schema(self, datafiles):
     yaml_file_path = datafiles.listdir()[0]
     with pytest.raises(Exception) as context:
         schema_validation.validate_yaml(yaml_file_path, __schema_url__)
     assert schema_validation.YAML_NOT_CONFIRM_MESSAGE in str(context.value)
Example #10
0
 def test_broken_yaml(self, datafiles):
     yaml_file_path = datafiles.listdir()[0]
     with pytest.raises(Exception) as context:
         schema_validation.validate_yaml(yaml_file_path, __schema_url__)
     assert 'This is not a valid yaml file' in str(context.value)
 def test_empty(self, datafiles):
     yaml_file_path = datafiles.listdir()[0]
     with pytest.raises(Exception) as context:
         schema_validation.validate_yaml(yaml_file_path, __schema_url__)
     assert 'Empty file' in str(context.value)