Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Pin PyYAML==3.13 and fix unit tests #37

Merged
merged 4 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions pyraml/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ def _handle_load(self, data):
if isinstance(data, ParserRamlInclude):
file_content, file_type = self._load_resource(data.file_name)

if not _is_mime_type_raml(file_type):

file_content_dict = {}
file_content_dict['fileName'] = data.file_name
file_content_dict['content'] = file_content
file_content = json.dumps(file_content_dict)

if _is_mime_type_raml(file_type):
new_relative_path = _calculate_new_relative_path(
self.relative_path, data.file_name)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
long_description=README + '\n\n' + CHANGES,
install_requires=[
'setuptools',
'PyYAML>=3.10',
'PyYAML==3.13',
'six>=1.9.0',
],
tests_require=[
Expand Down
21 changes: 14 additions & 7 deletions tests/test_parser_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
except ImportError:
from xml.etree.ElementTree import Element as XMLElement

try:
from collections import OrderedDict
except ImportError:
# For python 2.6 additional package ordereddict should be installed
from ordereddict import OrderedDict


class RootParseTestCase(SampleParseTestCase):
""" Test parsing of:

Expand Down Expand Up @@ -201,7 +208,7 @@ def test_regression_include_body_example_json(self):
data = self.load('include-body-example-json.yaml')
responses = data.resources['/me'].methods['get'].responses[200]
json_response = responses.body['application/json']
self.assertEqual(json_response.example, '{"foo": "bar"}')
self.assertEqual(json_response.example, {u'foo': u'bar'})


class ResourceParseTestCase(SampleParseTestCase):
Expand Down Expand Up @@ -332,7 +339,7 @@ def test_method_body_json_parsed(self):
"required": False,
"type": "object"
})
self.assertEqual(appjson.example, '{ "input": "hola" }')
self.assertEqual(appjson.example, OrderedDict([(u'input', u'hola')]))
self.assertIsNone(appjson.formParameters)

def test_method_body_xml_parsed(self):
Expand Down Expand Up @@ -387,7 +394,7 @@ def test_method_responses_desc_body_parsed(self):
self.assertEqual(len(responses[200].body), 1)
self.assertEqual(
responses[200].body['application/json'].example,
'{ "key": "value" }')
OrderedDict([(u'key', u'value')]))
self.assertEqual(
responses[200].body['application/json'].schema,
'league-json')
Expand Down Expand Up @@ -482,7 +489,7 @@ def test_complex_resourcetypes_parsed(self):
self.assertEqual(len(post.responses), 1)
resp200 = post.responses[200]
self.assertEqual(resp200.body['application/json'].example,
'{ "message": "Foo" }')
OrderedDict([(u'message', u'Foo')]))


class TraitsParseTestCase(SampleParseTestCase):
Expand Down Expand Up @@ -536,7 +543,7 @@ def test_traits_responses_parsed(self):
resp200 = data.traits['orderable'].responses[200]
self.assertEqual(len(resp200.body), 1)
self.assertEqual(resp200.body['application/json'].example,
'{ "message": "Bar" }')
OrderedDict([(u'message', u'Bar')]))


class SecuritySchemesParseTestCase(SampleParseTestCase):
Expand Down Expand Up @@ -601,7 +608,7 @@ def test_describedby_body_parsed(self):
self.assertEqual(len(body), 2)
appjson = body['application/json']
self.assertDictEqual(appjson.schema, {"foo": "bar"})
self.assertEqual(appjson.example, '{ "input": "hola" }')
self.assertEqual(appjson.example, OrderedDict([(u'input', u'hola')]))
self.assertIsNone(appjson.formParameters)
xmlbody = body['text/xml']
self.assertIsInstance(xmlbody.schema, XMLElement)
Expand All @@ -627,7 +634,7 @@ def test_describedby_responses_parsed(self):
self.assertEqual(resp401.description, 'Bad or expired token')
self.assertEqual(len(resp401.body), 1)
self.assertEqual(resp401.body['application/json'].example,
'{ "message": "fail" }')
OrderedDict([(u'message', u'fail')]))
self.assertIsNone(resp401.body['application/json'].schema)

def test_describedby_not_provided(self):
Expand Down