Skip to content

Commit

Permalink
Add Test for Recursive Include Support
Browse files Browse the repository at this point in the history
To guard against regression, and prove functionality, added a test and
associated example data to make sure nested `!include` directives work
and a test to make sure loading non-yaml and non-json files works.
  • Loading branch information
Ben Hamill committed May 14, 2015
1 parent 202d879 commit 56230dc
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/data/examples/includes/all-the-properties.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#%RAML 0.8

external: !include properties.raml
foo: !include foo-properties.raml
not_yaml: !include not_yaml.txt
1 change: 1 addition & 0 deletions tests/data/examples/includes/not_yaml.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is just a string.
4 changes: 4 additions & 0 deletions tests/data/examples/nested-includes.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#%RAML 0.8
title: GitHub API Demo - Includes
version: v3
include_one: !include includes/all-the-properties.raml
4 changes: 4 additions & 0 deletions tests/data/examples/nonyaml-includes.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#%RAML 0.8
title: GitHub API Demo - Includes
version: v3
not_yaml: !include includes/not_yaml.txt
38 changes: 38 additions & 0 deletions tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,44 @@ def test_load_file():
assert dict_equal(raml, expected_data)


def test_load_file_with_nested_includes():
raml_file = os.path.join(EXAMPLES + "nested-includes.raml")
with open(raml_file) as f:
raml = loader.RAMLLoader().load(f)

expected_data = {
'include_one': {
'external': {
'propertyA': 'valueA',
'propertyB': 'valueB'
},
'foo': {
'foo': 'FooBar',
'bar': 'BarBaz'
},
'not_yaml': "This is just a string.",
},
'title': 'GitHub API Demo - Includes',
'version': 'v3'
}

assert dict_equal(raml, expected_data)


def test_load_file_with_nonyaml_include():
raml_file = os.path.join(EXAMPLES + "nonyaml-includes.raml")
with open(raml_file) as f:
raml = loader.RAMLLoader().load(f)

expected_data = {
'not_yaml': "This is just a string.",
'title': 'GitHub API Demo - Includes',
'version': 'v3'
}

assert dict_equal(raml, expected_data)


def test_load_string():
raml_str = ("""
- foo
Expand Down

0 comments on commit 56230dc

Please sign in to comment.