-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16cd0d0
commit c7d5a08
Showing
1 changed file
with
48 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
|
||
from protosaurus import Context | ||
from base64 import b64decode | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main() | ||
|
||
|
||
@pytest.fixture | ||
def ctx(): | ||
return Context() | ||
|
||
|
||
def test_invalid_proto(ctx): | ||
with pytest.raises(RuntimeError): | ||
ctx.add_proto('test', | ||
""" | ||
syntax = "proto3"; | ||
message test { | ||
data; | ||
} | ||
""") | ||
|
||
def test_invalid_message_type(ctx): | ||
with pytest.raises(RuntimeError): | ||
ctx.add_proto('test', | ||
""" | ||
syntax = "proto3"; | ||
message test { | ||
bool data = 1; | ||
} | ||
""") | ||
|
||
ctx.as_json('invalid type', b64decode('CAE=')) | ||
|
||
def test_invalid_data(ctx): | ||
with pytest.raises(RuntimeError): | ||
ctx.add_proto('test', | ||
""" | ||
syntax = "proto3"; | ||
message test { | ||
bool data = 1; | ||
} | ||
""") | ||
|
||
ctx.as_json('test', b'invalid data') |