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

Commit

Permalink
Enable strict specification parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Jun 8, 2017
1 parent 4e87261 commit afa0d06
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion badwolf/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def _deserialize(self, value, attr, data):
try:
result.append(self.container.deserialize(each))
except ValidationError as e:
result.append(e.data)
if e.data is not None:
result.append(e.data)
errors.update({idx: e.messages})

if errors:
Expand Down Expand Up @@ -166,6 +167,9 @@ class AnyDeploySchema(OneOfSchema):


class SpecificationSchema(Schema):
class Meta:
strict = True

image = fields.String(missing=None)
dockerfile = fields.String(missing='Dockerfile')
docker = fields.Boolean(missing=False)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_spec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import io

import pytest
from marshmallow import Schema, fields

from badwolf.spec import Specification
Expand Down Expand Up @@ -473,3 +474,14 @@ def test_deploy_multiple_provider(app):
assert pypi.provider == 'pypi'
assert pypi.username == 'test'
assert pypi.password == 'test'


def test_deploy_single_provider_object_should_fail(app):
from badwolf.exceptions import InvalidSpecification

s = """deploy:
script: echo test
tag: true"""
f = io.StringIO(s)
with pytest.raises(InvalidSpecification):
Specification.parse_file(f)

0 comments on commit afa0d06

Please sign in to comment.