mirror of
https://github.com/netbox-community/devicetype-library.git
synced 2024-11-07 09:04:35 +01:00
Closes #27: Check that definition files end with a blank line
This commit is contained in:
parent
bbe3ab6542
commit
1c98c069b8
@ -32,6 +32,7 @@ Additionally, be sure to adhere to the following style guidance:
|
||||
* Use two spaces for indenting.
|
||||
* Specify a device type's attributes before listing its components.
|
||||
* Avoid encapsulating YAML values in quotes unless necessary to avoid a syntax error.
|
||||
* End each definition file with a blank line.
|
||||
|
||||
## The Contribution Workflow
|
||||
|
||||
|
@ -32,14 +32,20 @@ def test_environment():
|
||||
@pytest.mark.parametrize("file_path", _get_definition_files())
|
||||
def test_definition(file_path):
|
||||
"""
|
||||
Validate DeviceType definitions using the provided JSON schema.
|
||||
Validate each DeviceType definition file using the provided JSON schema.
|
||||
"""
|
||||
# Check file extension
|
||||
assert file_path.split('.')[-1] in ('yaml', 'yml'), f"Invalid file extension: {file_path}"
|
||||
|
||||
# Read file
|
||||
with open(file_path) as definition_file:
|
||||
definition = yaml.load(definition_file.read(), Loader=yaml.SafeLoader)
|
||||
content = definition_file.read()
|
||||
|
||||
# Check for trailing newline
|
||||
assert content[-1] == '\n', "Missing trailing newline"
|
||||
|
||||
# Load YAML data
|
||||
definition = yaml.load(content, Loader=yaml.SafeLoader)
|
||||
|
||||
# Run validation
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user