Example #1
0
    def test_must_get_body_directly(self, parse_mock):
        body = {'this': 'swagger'}

        reader = SwaggerReader(definition_body=body)
        parse_mock.return_value = None  # No location is returned from aws_include parser

        actual = reader._read_from_definition_body()
        self.assertEquals(actual, body)
Example #2
0
    def test_must_work_with_include_transform(self, parse_mock):
        body = {'this': 'swagger'}
        expected = {'k': 'v'}
        location = "some location"

        reader = SwaggerReader(definition_body=body)
        reader._download_swagger = Mock()
        reader._download_swagger.return_value = expected
        parse_mock.return_value = location

        actual = reader._read_from_definition_body()
        self.assertEquals(actual, expected)
        parse_mock.assert_called_with(body)
Example #3
0
    def test_must_read_first_from_definition_body(self):
        body = {"this is": "swagger"}
        uri = "./file.txt"
        expected = {"some": "value"}

        reader = SwaggerReader(definition_body=body, definition_uri=uri)
        reader._download_swagger = Mock()
        reader._read_from_definition_body = Mock()
        reader._read_from_definition_body.return_value = expected

        actual = reader.read()
        self.assertEquals(actual, expected)

        reader._read_from_definition_body.assert_called_with()
        reader._download_swagger.assert_not_called()
Example #4
0
    def test_must_use_definition_uri_if_body_does_not_exist(self):
        body = {"this is": "swagger"}
        uri = "./file.txt"
        expected = {"some": "value"}

        reader = SwaggerReader(definition_body=body, definition_uri=uri)
        reader._download_swagger = Mock()
        reader._download_swagger.return_value = expected

        # Set the output of reading the definition body to be None
        reader._read_from_definition_body = Mock()
        reader._read_from_definition_body.return_value = None

        actual = reader.read()
        self.assertEquals(actual, expected)

        reader._read_from_definition_body.assert_called_with()
        reader._download_swagger.assert_called_with(uri)