-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
100% test-coverage rule added to tox (#109)
* version bump Signed-off-by: Curtis Mason <cumason@google.com> * adding tests for marshaller Signed-off-by: Curtis Mason <cumason@google.com> * marshaller 100% test-coverage Signed-off-by: Curtis Mason <cumason@bu.edu> * bricked some tests Signed-off-by: Curtis Mason <cumason@bu.edu> * additional error handling Signed-off-by: Curtis Mason <cumason@bu.edu> * 100% test-coverage Signed-off-by: Curtis Mason <cumason@bu.edu> * handles empty data and capitalized headers Signed-off-by: Curtis Mason <cumason@bu.edu> * 1.1.0 version bump Signed-off-by: Curtis Mason <cumason@bu.edu>
- Loading branch information
1 parent
d95b130
commit 3c26bcf
Showing
19 changed files
with
479 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "1.0.1" | ||
__version__ = "1.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
import pytest | ||
|
||
import cloudevents.exceptions as cloud_exceptions | ||
from cloudevents.sdk.event import v1, v03 | ||
|
||
|
||
@pytest.mark.parametrize("event_class", [v1.Event, v03.Event]) | ||
def test_unmarshall_binary_missing_fields(event_class): | ||
event = event_class() | ||
with pytest.raises(cloud_exceptions.CloudEventMissingRequiredFields) as e: | ||
event.UnmarshalBinary({}, "", lambda x: x) | ||
assert "Missing required attributes: " in str(e.value) | ||
|
||
|
||
@pytest.mark.parametrize("event_class", [v1.Event, v03.Event]) | ||
def test_get_nonexistent_optional(event_class): | ||
event = event_class() | ||
event.SetExtensions({"ext1": "val"}) | ||
res = event.Get("ext1") | ||
assert res[0] == "val" and res[1] == True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
import pytest | ||
|
||
from cloudevents.sdk import exceptions | ||
from cloudevents.sdk.converters import base, binary, structured | ||
|
||
|
||
def test_binary_converter_raise_unsupported(): | ||
with pytest.raises(exceptions.UnsupportedEvent): | ||
cnvtr = binary.BinaryHTTPCloudEventConverter() | ||
cnvtr.read(None, {}, None, None) | ||
|
||
|
||
def test_base_converters_raise_exceptions(): | ||
with pytest.raises(Exception): | ||
cnvtr = base.Converter() | ||
cnvtr.event_supported(None) | ||
|
||
with pytest.raises(Exception): | ||
cnvtr = base.Converter() | ||
cnvtr.can_read(None) | ||
|
||
with pytest.raises(Exception): | ||
cnvtr = base.Converter() | ||
cnvtr.write(None, None) | ||
|
||
with pytest.raises(Exception): | ||
cnvtr = base.Converter() | ||
cnvtr.read(None, None, None, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.